Skip to content
New issue

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

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

Already on GitHub? # to your account

AttributeError: 'Response' object has no attribute 'status' #46

Open
Tonemon opened this issue Jan 31, 2021 · 1 comment
Open

AttributeError: 'Response' object has no attribute 'status' #46

Tonemon opened this issue Jan 31, 2021 · 1 comment

Comments

@Tonemon
Copy link

Tonemon commented Jan 31, 2021

  • Python Alexa Voice Service version: latest
  • Python version: 2.7
  • Operating System: (Respeaker Chaos Calmer v0.9.99)

Description

Hi, I just picked up this project after a while and I am trying to make this script working on boot.
I started with the information from #26 where @xiongyihui said to add it to the autorun.sh file.

What I Did

  • Added these lines to autorun.sh:
echo "executing run_alexa.sh script" > /dev/console
/root/run_alexa.sh &
  • Created new executable file called run_alexa.sh and added the following lines:
#!/bin/sh
cd /root/
echo "run_alexa.sh: changed working dir to:" > /dev/console
pwd > /dev/console


echo "run_alexa.sh: Starting 5 sec sleep process..." > /dev/console
sleep 5

echo "run_alexa.sh: done sleeping, running alexa in screen: sleepyalexa..." > /dev/console
echo "run_alexa.sh: to access this screen, type screen -r" > /dev/console
screen -dm -S sleepyalexa ash -c "alexa"

A new screen is being created at boot with the 'alexa' command and the light ring lights up, but after I say something, the alexa.py script crashes and it loops on this error:

WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
ERROR:avs.alexa:'Response' object has no attribute 'status'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 110, in run
    self._run()
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 129, in _run
    headers = {'authorization': 'Bearer {}'.format(self.token)}
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 360, in token
    "refresh token request returned {}".format(response.status))
AttributeError: 'Response' object has no attribute 'status'
INFO:avs.alexa:Refreshing access_token
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
INFO:requests.packages.urllib3.connectionpool:Resetting dropped connection: api.amazon.com
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
ERROR:avs.alexa:'Response' object has no attribute 'status'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 110, in run
    self._run()
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 129, in _run
    headers = {'authorization': 'Bearer {}'.format(self.token)}
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 360, in token
    "refresh token request returned {}".format(response.status))
AttributeError: 'Response' object has no attribute 'status'
INFO:avs.alexa:Refreshing access_token
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
INFO:requests.packages.urllib3.connectionpool:Resetting dropped connection: api.amazon.com
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"}
ERROR:avs.alexa:'Response' object has no attribute 'status'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 110, in run
    self._run()
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 129, in _run
    headers = {'authorization': 'Bearer {}'.format(self.token)}
  File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 360, in token
    "refresh token request returned {}".format(response.status))
AttributeError: 'Response' object has no attribute 'status'

Some notes:

  • I can start a new screen from SSH just fine (with screen ash -c "alexa") and deattach from it. Alexa keeps working and I can reattach to it whenever I want.
  • I can start a detached screen from SSH just fine (with screen -dm -S sleepyalexa ash -c "alexa") and Alexa keeps working in the background.

I just can't get it to start at boot without the error above. Does someone know how to fix it?

@Tonemon
Copy link
Author

Tonemon commented Feb 1, 2021

INFO:requests.packages.urllib3.connectionpool:Resetting dropped connection: api.amazon.com

After looking a bit closer in the code and errors I noticed that the connections to api.amazon.com are somehow being dropped and because of that, it does not receive a response, which causes this error. I find it weird that connections are being dropped when starting alexa in a detached screen at boot, but it works just fine when you start it via a SSH connection.

I get the following INFO message when running from a SSH connection:

INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.amazon.com

Does someone know how to fix it?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant