]> Nutra Git (v1) - gamesguru/getmyancestors.git/commitdiff
Add warning for code 403
authorBenoît Fontaine <benoitfontaine.ba@gmail.com>
Fri, 8 Dec 2017 13:39:22 +0000 (14:39 +0100)
committerBenoît Fontaine <benoitfontaine.ba@gmail.com>
Fri, 8 Dec 2017 13:39:22 +0000 (14:39 +0100)
getmyancestors.py

index 1be218764f0b6e54c81b2757f69caad6a6e1bbb4..0c80461ed0969bd0e3593d7582dc0fdfe429745c 100755 (executable)
@@ -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()