mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-05-31 15:49:41 +03:00
Correctly report when Companion server is down
This commit is contained in:
parent
d5e327e8e2
commit
23fcf5d950
16
companion.py
16
companion.py
@ -208,11 +208,7 @@ class Session:
|
|||||||
if __debug__: print_exc()
|
if __debug__: print_exc()
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
|
|
||||||
if r.status_code != requests.codes.ok:
|
if r.status_code != requests.codes.ok or 'server error' in r.text:
|
||||||
self.dump(r)
|
|
||||||
r.raise_for_status()
|
|
||||||
|
|
||||||
if 'server error' in r.text:
|
|
||||||
self.dump(r)
|
self.dump(r)
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
elif r.url == URL_LOGIN: # would have redirected away if success
|
elif r.url == URL_LOGIN: # would have redirected away if success
|
||||||
@ -229,8 +225,7 @@ class Session:
|
|||||||
if not code:
|
if not code:
|
||||||
raise VerificationRequired()
|
raise VerificationRequired()
|
||||||
r = self.session.post(URL_CONFIRM, data = {'code' : code}, timeout=timeout)
|
r = self.session.post(URL_CONFIRM, data = {'code' : code}, timeout=timeout)
|
||||||
r.raise_for_status()
|
if r.status_code != requests.codes.ok or r.url == URL_CONFIRM: # would have redirected away if success
|
||||||
if r.url == URL_CONFIRM: # would have redirected away if success
|
|
||||||
raise VerificationRequired()
|
raise VerificationRequired()
|
||||||
self.save() # Save cookies now for use by command-line app
|
self.save() # Save cookies now for use by command-line app
|
||||||
self.login()
|
self.login()
|
||||||
@ -248,14 +243,15 @@ class Session:
|
|||||||
if __debug__: print_exc()
|
if __debug__: print_exc()
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
|
|
||||||
if r.status_code != requests.codes.ok:
|
|
||||||
self.dump(r)
|
|
||||||
if r.status_code == requests.codes.forbidden or r.url == URL_LOGIN:
|
if r.status_code == requests.codes.forbidden or r.url == URL_LOGIN:
|
||||||
# Start again - maybe our session cookie expired?
|
# Start again - maybe our session cookie expired?
|
||||||
self.state = Session.STATE_INIT
|
self.state = Session.STATE_INIT
|
||||||
return self.query()
|
return self.query()
|
||||||
|
|
||||||
r.raise_for_status()
|
if r.status_code != requests.codes.ok:
|
||||||
|
self.dump(r)
|
||||||
|
raise ServerError()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = r.json()
|
data = r.json()
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user