Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the response status code before parsing time, raise more verbose error #63

Merged
merged 1 commit into from
Jan 28, 2020

Conversation

brentru
Copy link
Member

@brentru brentru commented Jan 28, 2020

Addressing: #57

Previous error with invalid Adafruit IO Account:

Traceback (most recent call last):
  File "code.py", line 44, in <module>
  File "adafruit_pyportal.py", line 629, in get_local_time
  File "adafruit_pyportal.py", line 625, in get_local_time
ValueError: invalid syntax for integer with base 10 

New code check status code. Error text pulled from response's text:

Traceback (most recent call last):
  File "code.py", line 25, in <module>
  File "/lib/adafruit_pyportal.py", line 635, in get_local_time
  File "/lib/adafruit_pyportal.py", line 624, in get_local_time
ValueError: {"error":"not found - that username does not exist"}

Correct operation (status code 200 OK):

Getting time for timezone America/New_York
Time request:  https://io.adafruit.com/api/v2/USERNAME/integrations/time/strftime?x-aio-key=aio_idOM89t6ejKZ03uzX5cU1taV3Sxv&tz=America/New_York&fmt=%25Y-%25m-%25d+%25H%3A%25M%3A%25S.%25L+%25j+%25u+%25z+%25Z
Time reply:  2020-01-28 11:38:00.983 028 2 -0500 EST
struct_time(tm_year=2020, tm_mon=1, tm_mday=28, tm_hour=11, tm_min=38, tm_sec=0, tm_wday=2, tm_yday=28, tm_isdst=None)

@brentru brentru requested a review from a team January 28, 2020 16:38
Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm did not test

@jepler jepler merged commit c920305 into adafruit:master Jan 28, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 29, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_HT16K33 to 3.2.1 from 3.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#58 from makermelissa/set_digit_raw

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.1.8 from 3.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#63 from brentru/check-response-status-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants