Pythonic API to WMO OSCAR Web Services
Project description
pyoscar
Pythonic API to WMO OSCAR
Overview
pyoscar provides a Pythonic API atop the WMO OSCAR HTTP API.
Installation
Requirements
- Python 3
- virtualenv or Conda
Dependencies
Dependencies are listed in requirements.txt. Dependencies are automatically installed during pyoscar installation.
Installing pyoscar
For users
To install the latest stable version:
pip3 install pyoscar
To keep up to date with stable updates:
pip3 install pyoscar -U
For developers
# setup virtualenv
python3 -m venv pyoscar
cd pyoscar
source bin/activate
# clone codebase and install
git clone https://github.com/wmo-cop/pyoscar.git
cd pyoscar
python3 setup.py build
python3 setup.py install
Running pyoscar via the Command Line
# help
pyoscar --help
# get version
pyoscar --version
# all subcommands support the following options:
# --env (depl or prod, default depl)
# --verbosity (ERROR, WARNING, INFO, DEBUG, default NONE)
# get all station identifiers
pyoscar stations
# get all station identifiers by country
pyoscar stations --country=CAN
# get all station identifiers by program affiliation
pyoscar stations --program=GAW
# get a single station by WIGOS identifier
pyoscar station 0-20000-0-71151
# get a single station by WIGOS identifier in summary mode
pyoscar station 0-20000-0-71151 --summary
# get a single station by WIGOS identifier in WIGOS XML format
pyoscar station 0-20000-0-71151 --format=XML
# get a single station by WIGOS identifier in WIGOS XML format in summary mode
pyoscar station 0-20000-0-71151 --format=XML --summary
# add verbose mode (ERROR, WARNING, INFO, DEBUG)
pyoscar station 0-20000-0-71151 --verbosity=DEBUG
# get contact by country
pyoscar contact -c Canada
# get contact by surname
pyoscar contact -s Karn
# get contact by organization
pyoscar contact -o "Environment Canada"
# upload WMDR XML (to production environment)
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod
# upload WMDR XML (to production environment) and save results to file
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod -l results.log
# use only GML ids is TRUE by default; use --no-gml-ids to set to FALSE
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod -l results.log --no-gml-ids
# harvest all records
pyoscar harvest --env=prod --directory=/path/to/dir
Using the pyoscar API
from pyoscar import OSCARClient
client = OSCARClient()
# get all Canadian stations
stations = client.get_stations(country='CAN')
# get all Canadian stations
stations = client.get_stations(program='GAW')
# get invididual station report
stn_leo = client.get_station_report('0-20000-0-71758')
# get invididual station report in summary mode
stn_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 production
client = OSCARClient(api_token='foo', env='prod')
with open('some-wmdr-file.xml') as fh:
data = fh.read()
response = client.upload(data)
Development
Running Tests
# install dev requirements
pip3 install -r requirements-dev.txt
# run tests like this:
cd tests
python3 run_tests.py
# or like this:
python3 setup.py test
# measure code coverage
coverage run --source pyoscar setup.py test
coverage report -m
create release (x.y.z is the release version)
vi pyoscar/init.py # update version git 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 --tags
upload to PyPI
rm -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 dev
vi pyoscar/init.py # update version git commit -am 'back to dev' git push origin master
Code Conventions
Bugs and Issues
All bugs, enhancements and issues are managed on GitHub.
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyoscar-0.6.4.tar.gz
.
File metadata
- Download URL: pyoscar-0.6.4.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f1082238748a7f6c216be9b089d4922a16a3cf377e397346a954eeed99988b1 |
|
MD5 | 858646dcdd4fad5c459ba84dd0e90d44 |
|
BLAKE2b-256 | c26e018dbbc6e83dbc099b8e4db13b6103751f52eb147a0b51293c1482cb37e5 |
File details
Details for the file pyoscar-0.6.4-py2.py3-none-any.whl
.
File metadata
- Download URL: pyoscar-0.6.4-py2.py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e25a018c564ec3652acc8a6271d9f6de24abc72abc365748a59309fd4d6afeb |
|
MD5 | d632a753ea8489c585f7d21996533613 |
|
BLAKE2b-256 | b11d9955ca56bbd21bca08b2ed7e52ff321fb7e7d0af338d99f731082a169d3d |