titilambert / pyhydroquebec

DEPRECATED - Get your consumption data from your HydroQuebec account (www.hydroquebec.com)
Apache License 2.0
94 stars 44 forks source link

average_temperature from current_daily_data can be None #50

Open llluis opened 4 years ago

llluis commented 4 years ago

Describe the bug If you query HQ close to midnight, data is still being rolled out. One corner case is already taken care of (yesterday - 1). But, HQ will release the consumption without average_temperature.

image

If you query during this interval, you get None and code can crash.

Traceback (most recent call last):
  File "/usr/local/bin/pyhydroquebec", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/pyhydroquebec/__main__.py", line 168, in main
    output_text(results[0], args.hourly)
  File "/usr/local/lib/python3.7/site-packages/pyhydroquebec/outputter.py", line 24, in output_text
    print(YESTERDAY_TPL.format(d=data))
TypeError: unsupported format string passed to NoneType.__format__

To Reproduce Run the std use case

pyhydroquebec -u XXX -p XXX

Expected behavior No errors. :)

PyHydroQuebec and Python version Python 3.7.5 PyHydroQuebec 3.0.0 (master as of today)

Corner Cases Are you in one of this situations: