Closed hikaru78 closed 4 years ago
Have you tried turning it off and on again?
Rebooted ... Still same issue
On Sun, 15 Dec. 2019, 11:26 NGPriest, notifications@github.com wrote:
Have you tried turning it off and on again?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/freyta/7Eleven-Python/issues/45?email_source=notifications&email_token=AEVC3CMQ3M5X2XRYOPLWUVTQYWBVJA5CNFSM4J25OB52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4PBDQ#issuecomment-565768334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVC3CI7CSFIAG4TUN6AWDLQYWBVJANCNFSM4J25OB5Q .
Is it still happening? Can you load https://projectzerothree.info/api.php?format=json ? That's where the error is happening, when it tries to find the cheapest price of fuel from Project Three Zero
Edit: when printing the result of the request I'm getting this response, so it is an error on the ProjectZeroThree side of things.
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
Projectzerothree updated their API to deny requests if they lack a User-Agent
header in the request. If you add a header to the request, it'll work.
r = requests.get(PRICE_URL, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.0 Safari/537.36 Edg/80.0.360.0'})
updated line in functions py to match LynnAU suggestion and is working now
Yep. So the problem is that the ProjectZeroThree website needs a custom user-agent to make requests. By default requests uses 'python-requests' which when we use that it just gives us an error. I've pushed an update (just noticed so did @beaudeanadams).
running Linux ubuntu 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux with python3
I added the below to the functions.py, I can login now,
r = requests.get(PRICE_URL, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.0 Safari/537.36 Edg/80.0.360.0'})
but it fails to lockin with below error - I still get an internal server error
192.168.1.105 - - [16/Dec/2019 13:29:49] "GET / HTTP/1.1" 200 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/css/style.css HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/images/7-eleven_logo.svg HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/fonts/PoiretOne-Regular.ttf HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:57] "POST /login HTTP/1.1" 302 - 192.168.1.105 - - [16/Dec/2019 13:29:59] "GET / HTTP/1.1" 200 - [2019-12-16 13:30:17,628] ERROR in app: Exception on /lockin [POST] Traceback (most recent call last): File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/griad/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "app.py", line 293, in lockin locationResult = functions.cheapestFuel(fuelType) File "/home/griad/7eleven/7Eleven-Python/functions.py", line 126, in cheapestFuel response = json.loads(r.text) File "/usr/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 192.168.1.105 - - [16/Dec/2019 13:30:17] "POST /lockin HTTP/1.1" 500 -
running Linux ubuntu 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux with python3
I added the below to the functions.py, I can login now,
r = requests.get(PRICE_URL, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.0 Safari/537.36 Edg/80.0.360.0'})
but it fails to lockin with below error - I still get an internal server error
192.168.1.105 - - [16/Dec/2019 13:29:49] "GET / HTTP/1.1" 200 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/css/style.css HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/images/7-eleven_logo.svg HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/fonts/PoiretOne-Regular.ttf HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:57] "POST /login HTTP/1.1" 302 - 192.168.1.105 - - [16/Dec/2019 13:29:59] "GET / HTTP/1.1" 200 - [2019-12-16 13:30:17,628] ERROR in app: Exception on /lockin [POST] Traceback (most recent call last): File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/griad/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "app.py", line 293, in lockin locationResult = functions.cheapestFuel(fuelType) File "/home/griad/7eleven/7Eleven-Python/functions.py", line 126, in cheapestFuel response = json.loads(r.text) File "/usr/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 192.168.1.105 - - [16/Dec/2019 13:30:17] "POST /lockin HTTP/1.1" 500 -
@gmharoun Please raise a new issue for this as all issues around the UserAgent were fixed and it would be unrelated to this issue. Please use the latest commit of the Master branch.
It appears more than once.. so you probaby missed the an instance.. just pull the latest
On Mon, 16 Dec. 2019, 12:34 gmharoun, notifications@github.com wrote:
running Linux ubuntu 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux with python3
I added the below to the functions.py, I can login now,
r = requests.get(PRICE_URL, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.0 Safari/537.36 Edg/80.0.360.0'})
but it fails to lockin with below error - I still get an internal server error
192.168.1.105 - - [16/Dec/2019 13:29:49] "GET / HTTP/1.1" 200 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/css/style.css HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/images/7-eleven_logo.svg HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:49] "GET /static/fonts/PoiretOne-Regular.ttf HTTP/1.1" 304 - 192.168.1.105 - - [16/Dec/2019 13:29:57] "POST /login HTTP/1.1" 302 - 192.168.1.105 - - [16/Dec/2019 13:29:59] "GET / HTTP/1.1" 200 - [2019-12-16 13:30:17,628] ERROR in app: Exception on /lockin [POST] Traceback (most recent call last): File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/griad/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/griad/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint http://**req.view_args File "app.py", line 293, in lockin locationResult = functions.cheapestFuel(fuelType) File "/home/griad/7eleven/7Eleven-Python/functions.py", line 126, in cheapestFuel response = json.loads(r.text) File "/usr/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 192.168.1.105 - - [16/Dec/2019 13:30:17] "POST /lockin HTTP/1.1" 500 -
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/freyta/7Eleven-Python/issues/45?email_source=notifications&email_token=AEVC3CJIKAYUVXUMET6BM5TQY3SMXA5CNFSM4J25OB52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG5KR6Y#issuecomment-565881083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVC3CKSO52OFUWU5C4K2DDQY3SMXANCNFSM4J25OB5Q .
@hikaru78 i just figured it out now, i missed one.
thanks @hikaru78 @beaudeanadams
windows 10 x64 python 3.8 was working until this morning
Note: You have not set a device ID. A random one will be set when you login. Note: Opening stores.json