Make sure we're returning the result of the recursive request

This commit is contained in:
M. Adam Kendall 2015-01-25 21:33:57 -05:00
parent a3bb636df2
commit 9cfc3e3788
1 changed files with 6 additions and 2 deletions

View File

@ -29,7 +29,11 @@ class TraktAPI():
resp.raise_for_status()
resp = resp.json()
except (requests.HTTPError, requests.ConnectionError) as e:
if e.response.status_code == 401:
if e.response.status_code == 502:
# Retry the request, cloudflare had a proxying issue
logger.log(u"Retrying trakt api request: auth/login", logger.WARNING)
return self.validateAccount()
elif e.response.status_code == 401:
raise traktAuthException(e)
if 'token' in resp:
self.token = resp['token']
@ -57,7 +61,7 @@ class TraktAPI():
if e.response.status_code == 502:
# Retry the request, cloudflare had a proxying issue
logger.log(u"Retrying trakt api request: %s" % path, logger.WARNING)
self.traktRequest(path, data, method)
return self.traktRequest(path, data, method)
elif e.response.status_code == 401:
raise traktAuthException(e)
elif e.response.status_code == 503: