freyta / 7Eleven-Python

A python script to check fuel prices and also lock them in
GNU General Public License v3.0
128 stars 63 forks source link

Error when login #33

Closed dn4hc closed 5 years ago

dn4hc commented 5 years ago

[2019-08-02 20:12:24,397] ERROR in app: Exception on /login [POST]
Traceback (most recent call last):
  File "app.py", line 145, in login
    if(returnContent['Message']):
KeyError: 'Message'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home//.local/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home//.local/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home//.local/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home//.local/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home//.local/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home//.local/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "app.py", line 170, in login
    functions.lockedPrices()
  File "/home//7Eleven-Python/functions.py", line 175, in lockedPrices
    returnContent = json.loads(response.content)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
MattKobayashi commented 5 years ago

This doesn't give much information. What platform are you trying to run the script on? When is this error occurring? Have you followed the instructions in the readme?

dn4hc commented 5 years ago

Raspbian on Raspberry Pi 2, I can start the script successfully however this error occurs when logging in.

Screen Shot 2019-08-03 at 1 58 43 am
dn4hc commented 5 years ago

this fixed it in /7Eleven-Python/functions.py

returnContent = json.loads(response.content) **to**
returnContent = json.loads(str(response.content, "utf-8"))
dn4hc commented 5 years ago

Getting the same error again when locking in

[2019-08-13 05:28:16,378] ERROR in app: Exception on /lockin [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "app.py", line 359, in lockin
    returnContent = json.loads(returnContent)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
freyta commented 5 years ago

Does it happen when you login too? Or when you logout?

dn4hc commented 5 years ago

Login works fine. Only when locking.

freyta commented 5 years ago

Are you using the latest version of app.py? Your error says that line 359 is returnContent = json.loads(returnContent), whereas the current version line 359 is # If there is a fuel lock already in place we get an error!.

What does the very first line of your app.py say? It should begin with #-*- coding: utf8 -*-

evo87 commented 5 years ago

Im getting same error, only when locking in using new version of app.py

[2019-08-22 13:22:25,979] ERROR in app: Exception on /lockin [POST] Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "app.py", line 357, in lockin returnContent = json.loads(returnContent) File "/usr/lib/python3.5/json/__init__.py", line 312, in loads s.__class__.__name__)) TypeError: the JSON object must be str, not 'bytes'

NGPriest commented 5 years ago

Should we close this issue? :S