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:
pip install pyoscar
To keep up to date with stable updates:
pip 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
python setup.py build
python 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 --identifier 0-20000-0-71151
# get a single station by WIGOS identifier in WIGOS XML format
pyoscar station --identifier 0-20000-0-71151 --format=XML
# add verbose mode (ERROR, WARNING, INFO, DEBUG)
pyoscar station --identifier 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
# 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('LEO')
# 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
pip install -r requirements-dev.txt
# run tests like this:
cd tests
python run_tests.py
# or like this:
python setup.py test
# measure code coverage
coverage run --source pyoscar setup.py test
coverage report -m
Releasing
python setup.py sdist bdist_wheel --universal
twine upload dist/*
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
pyoscar-0.4.0.tar.gz
(8.4 kB
view details)
Built Distribution
File details
Details for the file pyoscar-0.4.0.tar.gz
.
File metadata
- Download URL: pyoscar-0.4.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 347eacac95da7f9430f2dd0d7324e04ca78dba91e39629872e3612644a751ba4 |
|
MD5 | dd5b0a871833f269ec70f7abc335f08f |
|
BLAKE2b-256 | b04fd4135539c824594f091e78cc754c64979ea7d7ccc814d9722880c8b60e81 |
File details
Details for the file pyoscar-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pyoscar-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f08b29e7c2a41d1ccc24e1a924b5781ae3b0321b490f8099843684bbc84229 |
|
MD5 | 56b2da96b5b3536178092ee08dbc0bd1 |
|
BLAKE2b-256 | 21fed9dd38492a89e43abcc7186648fcfa654962dcef6f4abad1571fc37129c7 |