-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Small fix preventing docker from building correctly * 202 discard outdated forecast (#205) * Small fix preventing docker from building correctly * Fixes #202 * 199 fix coveralls (#206) * testing travis-ci build after this mod... * another test * now showing coverage on the master branch instead of the develop one * now it should be OK * 210 unicode error (#213) * Fix integration test * Possible fix, needs testing * Making Travis-CI work * Fixes #216 * Fixes #219 * Alpine docker and switch to tox-travis (#222) * Dockerfiles and build utils for Alpine containers * Refactored examples/getTemp.py * More refactoring due to codeclimate warnings * switch to tox-travis * add Simone-Zabberoni to contributors * update of Linux distro for Travis CI builds * rename * moved to online Wiki * Renamed dockerfiles for Alpine images * improved build script * Renamed dockerfile for ubuntu * UK is wrong - GB is right * Dockerfiles into one single folder; adapted Docker build and publish scripts; moved test script * fix * Fix for #224 * 137 Stations API support (#225) * Introducing requests as new convenience HTTP client * New deprecation to be executed upon future version 3.0.0 * Updated with some fixes * New germinal HTTP Client class * Cleaned * Refactoring * More refactoring, and introducing StationsManagaer class * forgot * Station entity, parser and tests; adding more stations_manager methods * fixing broken build on travis-ci * Refactoring to allow class deprecations * More tests and namespace * time properties in different formats * Refactoring and more tests * Seems like IDs are returned with capitalized letters in JSON - and also altitudes can be optional * Proper testing and stations_manager.create_station * Trying to fix broken Travis-CI build * Implemented update of stations (PUT) * IMplemented deletion of stations (DELETE) * Fix bug on microseconds parsing * Integration test * Fix imports * Fix documentation * Forgot * Fix docs * AggregatedMeasurement and Measurement classes and their unit tests * Buffer class and tests * PersistenceBackends and tests * CI build is broken, trying to use an old Linux image for builds * method skeletons * One more method * Parser for AggregatedMeasurement objects from JSON * Stations Manager methods related to measurements and buffer handling * Committing old work (might break tests) * refactored stations api version out * docs * fix issue with timestamps not having microseconds * this way empty payloads are handled OK * No prints, baby * Now working * Defaulted to 100 the number of measurements that can be retrieved by the Stations API; fixed data blob sent when posting measurements * otherwise TRavis-CI builds won't start * Add few methods to query for "clear" conditions; deprecated on v3.0 the ones querying for "sun" conditions (#227) * remove diff fragments * Fix error * Updated city ID database files * removed usage of deprecated method * fix broken test * bump to version 2.8.0 * documentation and usage examples
- Loading branch information
Showing
68 changed files
with
2,869 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM alpine:3.7 | ||
MAINTAINER Claudio Sparpaglione <[email protected]> | ||
|
||
# Install apk packages | ||
RUN apk add --update python python3 python-dev python3-dev py-pip | ||
RUN apk add --update wget gcc linux-headers musl-dev ca-certificates zlib && \ | ||
apk add --update gobject-introspection py-gobject py-dbus | ||
|
||
# Mount latest source code | ||
ADD . /pyowm | ||
WORKDIR /pyowm | ||
COPY tests/get_temperature.py /usr/bin | ||
|
||
# | ||
RUN python setup.py install && \ | ||
pip install ipython && \ | ||
pip3 install ipython && \ | ||
pip install -r /pyowm/dev-requirements.txt && \ | ||
pip3 install -r /pyowm/dev-requirements.txt | ||
|
||
# Deprecated: Install setuptools and setuptools3 | ||
#RUN wget https://bootstrap.pypa.io/ez_setup.py -O - | python && \ | ||
# wget https://bootstrap.pypa.io/ez_setup.py -O - | python3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM alpine:3.7 | ||
MAINTAINER Claudio Sparpaglione <[email protected]> | ||
|
||
RUN apk add --update python py-pip | ||
ADD . /pyowm | ||
WORKDIR /pyowm | ||
COPY tests/get_temperature.py /usr/bin | ||
RUN python setup.py install | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM alpine:3.7 | ||
MAINTAINER Claudio Sparpaglione <[email protected]> | ||
|
||
RUN apk add --update python3 py-pip | ||
|
||
ADD . /pyowm | ||
WORKDIR /pyowm | ||
COPY tests/get_temperature.py /usr/bin | ||
RUN python setup.py install | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import requests | ||
from pyowm.exceptions import api_call_error, unauthorized_error, not_found_error, \ | ||
parse_response_error | ||
|
||
|
||
class HttpClient(object): | ||
|
||
def get_json(self, uri, params=None, headers=None): | ||
resp = requests.get(uri, params=params, headers=headers) | ||
HttpClient.check_status_code(resp.status_code, resp.text) | ||
try: | ||
return resp.status_code, resp.json() | ||
except: | ||
raise parse_response_error.ParseResponseError('Impossible to parse' | ||
'API response data') | ||
|
||
def post(self, uri, params=None, data=None, headers=None): | ||
resp = requests.post(uri, params=params, json=data, headers=headers) | ||
HttpClient.check_status_code(resp.status_code, resp.text) | ||
# this is a defense against OWM API responses cointaining an empty body! | ||
try: | ||
json_data = resp.json() | ||
except: | ||
json_data = {} | ||
return resp.status_code, json_data | ||
|
||
def put(self, uri, params=None, data=None, headers=None): | ||
resp = requests.put(uri, params=params, json=data, headers=headers) | ||
HttpClient.check_status_code(resp.status_code, resp.text) | ||
# this is a defense against OWM API responses cointaining an empty body! | ||
try: | ||
json_data = resp.json() | ||
except: | ||
json_data = {} | ||
return resp.status_code, json_data | ||
|
||
def delete(self, uri, params=None, data=None, headers=None): | ||
resp = requests.delete(uri, params=params, json=data, headers=headers) | ||
HttpClient.check_status_code(resp.status_code, resp.text) | ||
# this is a defense against OWM API responses cointaining an empty body! | ||
try: | ||
json_data = resp.json() | ||
except: | ||
json_data = None | ||
return resp.status_code, json_data | ||
|
||
|
||
@classmethod | ||
def check_status_code(cls, status_code, payload): | ||
if status_code < 400: | ||
return | ||
if status_code == 400: | ||
raise api_call_error.APICallError(payload) | ||
elif status_code == 401: | ||
raise unauthorized_error.UnauthorizedError('Invalid API Key provided') | ||
elif status_code == 404: | ||
raise not_found_error.NotFoundError('Unable to find the resource') | ||
elif status_code == 502: | ||
raise api_call_error.BadGatewayError('Unable to contact the upstream server') | ||
else: | ||
raise api_call_error.APICallError(payload) | ||
|
||
@classmethod | ||
def is_success(cls, status_code): | ||
if 200 <= status_code < 300: | ||
return True | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.