From 7ba2d2bc12acb4b437ddc24e4a9276b67f27d4a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Fontaine?= Date: Fri, 8 Dec 2017 14:39:22 +0100 Subject: [PATCH] Add warning for code 403 --- getmyancestors.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/getmyancestors.py b/getmyancestors.py index 1be2187..0c80461 100755 --- a/getmyancestors.py +++ b/getmyancestors.py @@ -195,9 +195,13 @@ class Session: except requests.exceptions.HTTPError: if self.verbose: self.logfile.write('[' + time.strftime("%Y-%m-%d %H:%M:%S") + ']: HTTPError\n') - if r.status_code == 403 and 'message' in r.json()['errors'][0] and r.json()['errors'][0]['message'] == u'Unable to get ordinances.': - self.logfile.write('Unable to get ordinances. Try with an LDS account or without option -c.\n') - exit() + if r.status_code == 403: + if 'message' in r.json()['errors'][0] and r.json()['errors'][0]['message'] == u'Unable to get ordinances.': + self.logfile.write('Unable to get ordinances. Try with an LDS account or without option -c.\n') + exit() + else: + self.logfile.write('Warning code 403 link: ' + url + ' ' + r.json()['errors'][0]['message'] or '') + return None time.sleep(self.timeout) continue return r.json() -- 2.52.0