persandstrom / python-verisure

A python module for reading and changing status of verisure devices through verisure app api.
MIT License
134 stars 42 forks source link

raise_for_status() #169

Closed niro1987 closed 1 year ago

niro1987 commented 1 year ago

reverse the urls if the first url return a non-200 response so that the same request can be tested on both urls before raising an error.

persandstrom commented 1 year ago

Not really put much thought into this, but would this result in an additional try if the response is for example "Unauthorized Request" ? And if so, would that be an issue?

niro1987 commented 1 year ago

Yes, any status >= 400 would result in an additional try. Let's say for example that the first url is unreachable (status 500), you would want a new try on the other url.

WIthout this PR, the except is never really triggered, because we either return the response if status_code == 200 or we raise ResponseError, which is not included in an except.

niro1987 commented 1 year ago

The last comment on issue 94028 shows that the server responded with 504 - Gateway Timeout. This could confirm my suspision that the SYS_00004 is no longer used and is now replaced with a 504.

persandstrom commented 1 year ago

Yes, sounds plausible. Please prepare this with new revision etc in setup and Readme. I can merge it but cannot do a new release to pip until tomorrow or the day after

persandstrom commented 1 year ago

Released to pypi