diff options
author | Martin Langhoff <martin@laptop.org> | 2012-05-22 21:40:50 (GMT) |
---|---|---|
committer | Martin Langhoff <martin@laptop.org> | 2012-05-23 19:38:07 (GMT) |
commit | b427a4b22cf0de7702e2bfddf6c1a6b4bfa421c0 (patch) | |
tree | 96c5d4af0e2eb176f2b71e7309eaf40220eecac1 | |
parent | f9267643cfe57bb71994f15d36ba90afc37b5d7b (diff) |
sugar_activity_group: retry on network/http errors #11885
OOB builds often fail on transient failures due to network or
server side issues. Maybe ASLO is a bit unreliable.
With this patch we report failures a bit more elegantly,
and we retry 5 times before giving up.
-rw-r--r-- | modules/sugar_activity_group/kspost.60.nochroot.activities.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/modules/sugar_activity_group/kspost.60.nochroot.activities.py b/modules/sugar_activity_group/kspost.60.nochroot.activities.py index f77a9e1..1bda46a 100644 --- a/modules/sugar_activity_group/kspost.60.nochroot.activities.py +++ b/modules/sugar_activity_group/kspost.60.nochroot.activities.py @@ -9,6 +9,7 @@ import os.path import urllib import urllib2 import urlparse +import time from bitfrost.update import microformat @@ -51,7 +52,24 @@ if install_activities: for name, info in results.items(): (version, url) = microformat.only_best_update(info) print >>sys.stderr, "Examining %s v%s: %s" % (name, version, url) - fd = urllib2.urlopen(url) + + fd = None + for attempts in range(5): + if attempts > 0: + print >>sys.stderr, 'Retrying.' + time.sleep(1) + try: + fd = urllib2.urlopen(url) + break + except urllib2.HTTPError, e: + print >>sys.stderr, 'HTTP error: ', e.code + except urllib2.URLError, e: + print >>sys.stderr, 'Network or server error: ', e.reason + + if not fd: + print >>sys.stderr, 'Could not reach ', url + sys.exit(1) + headers = fd.info() if not 'Content-length' in headers: raise Exception("No content length for %s" % url) |