Skip to main content

Pythonic API to WMO OSCAR Web Services

Project description

pyoscar

Pythonic API to WMO OSCAR

Build Status

Overview

pyoscar provides a Pythonic API atop the WMO OSCAR HTTP API.

Installation

Requirements

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 --identifier 0-20000-0-71151

# get a single station by WIGOS identifier in summary mode
pyoscar station --identifier 0-20000-0-71151 --summary

# get a single station by WIGOS identifier in WIGOS XML format
pyoscar station --identifier 0-20000-0-71151 --format=XML

# get a single station by WIGOS identifier in WIGOS XML format in summary mode
pyoscar station --identifier 0-20000-0-71151 --format=XML --summary

# 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

# 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

Releasing

python3 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


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.6.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

pyoscar-0.6.1-py2.py3-none-any.whl (10.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyoscar-0.6.1.tar.gz.

File metadata

  • Download URL: pyoscar-0.6.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.4

File hashes

Hashes for pyoscar-0.6.1.tar.gz
Algorithm Hash digest
SHA256 cbeedacdb9e4691d2610808657b92edb02c40854cda8c9aafce8eea5a01b6a4e
MD5 250dd470a6b9e1ee25337849c292b16c
BLAKE2b-256 3950be94599bc290fa59dc9428a9c5f3ac18f8106e681e84e6f50de1c537cdb2

See more details on using hashes here.

File details

Details for the file pyoscar-0.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pyoscar-0.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.4

File hashes

Hashes for pyoscar-0.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cc6ec6333d72d7e830d07f77c47e51ba6fdcfd4f7ebe0503edd4f15498472529
MD5 0fc72be0b742f153a980936590b7f383
BLAKE2b-256 95422e841c11574acececbf8c197ba78ec97c6adbf3e0611f6a7099a63f6561b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page