Package: pyoscar
pyoscarPythonic API to WMO OSCAROverviewpyoscar provides a Pythonic API atop the WMOOSCARHTTP API.InstallationRequirementsPython 3virtualenvorCondaDependenciesDependencies are listed inrequirements.txt. Dependencies
are automatically installed during pyoscar installation.Installing pyoscarFor usersTo install the latest stable version:pip3installpyoscarTo keep up to date with stable updates:pip3installpyoscar-UFor developers# setup virtualenvpython3-mvenvpyoscarcdpyoscarsourcebin/activate# clone codebase and installgitclonehttps://github.com/wmo-cop/pyoscar.gitcdpyoscar
python3setup.pybuild
python3setup.pyinstallRunning pyoscar via the Command Line# helppyoscar--help# get versionpyoscar--version# all subcommands support the following options:# --env (depl or prod, default depl)# --verbosity (ERROR, WARNING, INFO, DEBUG, default NONE)# get all station identifierspyoscarstations# get all station identifiers by countrypyoscarstations--country=CAN# get all station identifiers by program affiliationpyoscarstations--program=GAW# get a single station by WIGOS identifierpyoscarstation0-20000-0-71151# get a single station by WIGOS identifier in summary modepyoscarstation0-20000-0-71151--summary# get a single station by WIGOS identifier in WIGOS XML formatpyoscarstation0-20000-0-71151--format=XML# get a single station by WIGOS identifier in WIGOS XML format in summary modepyoscarstation0-20000-0-71151--format=XML--summary# add verbose mode (ERROR, WARNING, INFO, DEBUG)pyoscarstation0-20000-0-71151--verbosity=DEBUG# get contact by countrypyoscarcontact-cCanada# get contact by surnamepyoscarcontact-sKarn# get contact by organizationpyoscarcontact-o"Environment Canada"# upload WMDR XML (to production environment)pyoscarupload-x/path/to/wmdr.xml-atAPI_TOKEN-eprod# upload WMDR XML (to production environment) and save results to filepyoscarupload-x/path/to/wmdr.xml-atAPI_TOKEN-eprod-lresults.log# use only GML ids is TRUE by default; use --no-gml-ids to set to FALSEpyoscarupload-x/path/to/wmdr.xml-atAPI_TOKEN-eprod-lresults.log--no-gml-ids# harvest all recordspyoscarharvest--env=prod--directory=/path/to/dirUsing the pyoscar APIfrompyoscarimportOSCARClientclient=OSCARClient()# get all Canadian stationsstations=client.get_stations(country='CAN')# get all Canadian stationsstations=client.get_stations(program='GAW')# get invididual station reportstn_leo=client.get_station_report('0-20000-0-71758')# get invididual station report in summary modestn_leo=client.get_station_report('0-20000-0-71758',summary=True)# upload WMDR XML## instantiate client to OSCAR DEPL (default)client=OSCARClient(api_token='foo')## ...or to OSCAR productionclient=OSCARClient(api_token='foo',env='prod')withopen('some-wmdr-file.xml')asfh:data=fh.read()response=client.upload(data)DevelopmentRunning Tests# install dev requirementspip3install-rrequirements-dev.txt# run tests like this:cdtests
python3run_tests.py# or like this:python3setup.pytest# measure code coveragecoveragerun--sourcepyoscarsetup.pytestcoveragereport-mcreate release (x.y.z is the release version)vi pyoscar/init.py  # updateversiongit commit -am 'update release version x.y.z'
git push origin master
git tag -a x.y.z -m 'tagging release version x.y.z'
git push --tagsupload to PyPIrm -fr build dist.egg-info
python3 setup.py sdist bdist_wheel --universal
twine upload dist/publish release on GitHub (https://github.com/wmo-cop/pyoscar/releases/new)bump version back to devvi pyoscar/init.py  # updateversiongit commit -am 'back to dev'
git push origin masterCode ConventionsPEP8Bugs and IssuesAll bugs, enhancements and issues are managed onGitHub.ContactTom Kralidis