diff --git a/bin/updater.py b/bin/updater.py index 5eb8eded8..2942d9a2b 100644 --- a/bin/updater.py +++ b/bin/updater.py @@ -19,6 +19,11 @@ import requests import urllib +def check_status_code(response): + if response.status_code != 200: + raise Exception('Request failed with %i: %s' % (response.status_code, + response.text)) + class UpdateThread(threading.Thread): lock = threading.Lock() @@ -52,7 +57,8 @@ def run(self): try: auth = (self.user, self.password) - requests.get(url, auth=auth, timeout=self.timeout) + request = requests.get(url, auth=auth, timeout=self.timeout) + check_status_code(request) except (Exception) as e: print('%s: %s' % (url, e)) @@ -86,9 +92,12 @@ def run(self): # run the cleanup request and get all the feeds to update auth = (self.user, self.password) - requests.get(self.before_cleanup_url, auth=auth) + before = requests.get(self.before_cleanup_url, auth=auth) + check_status_code(before) feeds_response = requests.get(self.all_feeds_url, auth=auth) + check_status_code(feeds_response) + feeds_json = feeds_response.text feeds = json.loads(feeds_json)['feeds'] @@ -103,7 +112,8 @@ def run(self): for thread in threads: thread.join() - requests.get(self.after_cleanup_url, auth=auth) + after = requests.get(self.after_cleanup_url, auth=auth) + check_status_code(after) if self.run_once: return