Closed Peetz0r closed 7 years ago
Merged, but removed encoding fix, as this does not seem to work. Please submit new pull request with new fix if needed.
With the fix removed, it fails for me with:
>>> r.get_robot_state()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/peter/pybotvac/pybotvac/robot.py", line 73, in get_robot_state
return self._message({'reqId': "1", 'cmd': "getRobotState"})
File "/home/peter/pybotvac/pybotvac/robot.py", line 46, in _message
headers=self._headers)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 110, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 474, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 407, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 306, in prepare
self.prepare_auth(auth, url)
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 543, in prepare_auth
r = auth(self)
File "/home/peter/pybotvac/pybotvac/robot.py", line 111, in __call__
msg='\n'.join([self.serial.lower(), date, request.body.decode('utf8')]).encode('utf8'),
TypeError: sequence item 2: expected str instance, bytes found
With the fix removed, it used to work before, but now fails with:
>>> r.get_robot_state()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/peter/pybotvac/pybotvac/robot.py", line 73, in get_robot_state
return self._message({'reqId': "1", 'cmd': "getRobotState"})
File "/home/peter/pybotvac/pybotvac/robot.py", line 47, in _message
response.raise_for_status()
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 909, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://nucleo.neatocloud.com/vendors/neato/robots/OPSXXXXX-YYYYYYYYYYYY/messages
I get the same results on Ubuntu 14.04 with Python 3.4.3 and Ubuntu 16.04 with Python 3.5.2.
On Python 2.7.12 I get the 404 error both with and without the fix.
This seems to be due to a change between earlier versions of requests (2.10.0 in my case) and 2.13.0. The latest commit should work with both.
Signed-off-by: Hugo D. (jabesq) jabesq@gmail.com
Fixes https://github.com/stianaske/pybotvac/issues/3
This is an issue which happens on python3, doesn't happen on python2.