summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-01 23:00:07 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-01 23:00:07 +0200
commitb78b3fe215af482828434a41d771e7b84de8801e (patch)
treefa6b7420cf1e574a45a3ab8f060860c37774ed65
parent94b3fc78a17c9f7e7b1fbf7a3e4f426dc6003b05 (diff)
more verbose error messages
-rw-r--r--bin/updater.py16
1 files changed, 13 insertions, 3 deletions
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 threading
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 @@ class UpdateThread(threading.Thread):
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 @@ class Updater:
# 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 @@ class Updater:
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