use retry on urlopen
authorSylvestre Ledru <sledru@mozilla.com>
Thu, 04 Dec 2014 16:51:43 -0800
changeset 5240 e6544d496365e4534d516aa0db524ce3d48c05bc
parent 5239 c89d4f6c104b7069679a48689447f46c4853e293
child 5241 6e079fb7acac6c4651ea1fd012cc90e85c877535
push id4
push usersledru@mozilla.com
push dateFri, 05 Dec 2014 00:51:51 +0000
use retry on urlopen
buildbot-helpers/release_sanity.py
--- a/buildbot-helpers/release_sanity.py
+++ b/buildbot-helpers/release_sanity.py
@@ -112,40 +112,45 @@ def query_locale_revisions(l10n_changese
             locales[locale] = locales_json[locale]["revision"]
     else:
         for line in open(l10n_changesets, 'r'):
             locale, revision = line.split()
             locales[locale] = revision
     return locales
 
 
+def get_l10n_changesets(locale_url):
+    try:
+        urllib2.urlopen(locale_url)
+    except urllib2.HTTPError, e:
+        reason = ""
+        if hasattr(e, 'reason'):
+            # Python 2.6 does not have reason
+            reason = e.reason
+        log.error("error checking l10n changeset %s: %d %s" % (locale_url, e.code, reason))
+        success = False
+        error_tally.add('verify_l10n')
+
+
 def verify_l10n_changesets(hgHost, l10n_changesets):
     """Checks for the existance of all l10n changesets"""
     success = True
     locales = query_locale_revisions(l10n_changesets)
     for locale in sorted(locales.keys()):
         revision = locales[locale]
         localePath = '%(repoPath)s/%(locale)s/file/%(revision)s' % {
             'repoPath': releaseConfig['l10nRepoPath'].strip('/'),
             'locale': locale,
             'revision': revision,
         }
         locale_url = make_hg_url(hgHost, localePath, protocol='https')
         log.info("Checking for existence l10n changeset %s %s in repo %s ..."
                  % (locale, revision, locale_url))
-        try:
-            urllib2.urlopen(locale_url)
-        except urllib2.HTTPError, e:
-            reason = ""
-            if hasattr(e, 'reason'):
-                # Python 2.6 does not have reason
-                reason = e.reason
-            log.error("error checking l10n changeset %s: %d %s" % (locale_url, e.code, reason))
-            success = False
-            error_tally.add('verify_l10n')
+
+        retry(get_l10n_changesets, args=(locale_url), attempts=3, sleeptime=1)
     return success
 
 
 def verify_l10n_dashboard(l10n_changesets, l10n_dashboard_version=None):
     """Checks the l10n-changesets against the l10n dashboard"""
     success = True
     locales = query_locale_revisions(l10n_changesets)
     if l10n_dashboard_version: