Closed tinoest closed 7 years ago
Fixes #1
Running this patch on Python 2.7 gives an error
File "./download-usage.py", line 6, in <module>
from britishgas_myenergy_client import MyEnergyClient
File "/data/britishgas_myenergy_client/britishgas_myenergy_client.py", line 1, in <module>
import print_function
ImportError: No module named print_function
Changing to
from __future__ import print_function
seems to fix that, but they I observe the exception mentioned in https://github.com/andrew-blake/britishgas_myenergy_client/issues/1
$ ./download-usage.py
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/data/britishgas_myenergy_client/download-usage.py in <module>()
6 from britishgas_myenergy_client import MyEnergyClient
7
----> 8 client = MyEnergyClient(username=USERNAME, password=PASSWORD, proxies=PROXIES, debug=DEBUG, ssl_verify=SSL_VERIFY)
9
10 today = date.today()
/data/britishgas_myenergy_client/britishgas_myenergy_client.py in __init__(self, username, password, proxies, debug, ssl_verify)
63 self.is_initialised = False
64
---> 65 self._login()
66
67 def _unixtime_in_ms(self):
/data/britishgas_myenergy_client/britishgas_myenergy_client.py in _login(self)
127 self.response = json.loads(req1.content.decode())
128 self.is_authenticated = self.response['OAMAuthenticate']['isAuthenticated'] == u'TRUE'
--> 129 self.account_number = self.response['OAMAuthenticate']['Accounts'][0]['AccountNumber']
130 self.ucrn = self.response['OAMAuthenticate']['Accounts'][0]['CustomerDetails']['Ucrn']
131
KeyError: 'Accounts'
I didn't test it under python 2.7 as I don't have that installed im afraid.
It ran ok and downloaded all the content under 3.4 ok for me.
I was getting the account error when I used the wrong password/login credentials
Yes, using the right password helps.
Changed to talk with the latest Apple Client API and updated to work under python3.4