summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Hajdan, Jr <phajdan.jr@gentoo.org>2017-07-10 22:28:50 +0200
committerPawel Hajdan, Jr <phajdan.jr@gentoo.org>2017-07-10 22:28:50 +0200
commit064b7b3dbf4277b9c57add479a478386504fc0d2 (patch)
tree86ce96e6a71db9cfaccccbca1c1dee90ca9c2881
parentstabilization-candidates: update for git (diff)
downloadarch-tools-064b7b3dbf4277b9c57add479a478386504fc0d2.tar.gz
arch-tools-064b7b3dbf4277b9c57add479a478386504fc0d2.tar.bz2
arch-tools-064b7b3dbf4277b9c57add479a478386504fc0d2.zip
stabilization-candidates: retry network errorsHEADmaster
-rw-r--r--common.py19
-rwxr-xr-xstabilization-candidates.py26
2 files changed, 36 insertions, 9 deletions
diff --git a/common.py b/common.py
index 89e4996..8e0c14c 100644
--- a/common.py
+++ b/common.py
@@ -1,10 +1,12 @@
# Copyright 2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import functools
import io
import datetime
import getpass
import re
+import time
import portage
@@ -17,6 +19,23 @@ def chunks(iterable, length):
yield iterable[i:i + length]
+def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
+ def deco_retry(f):
+ @functools.wraps(f)
+ def f_retry(*args, **kwargs):
+ mtries, mdelay = tries, delay
+ while mtries > 1:
+ try:
+ return f(*args, **kwargs)
+ except ExceptionToCheck:
+ time.sleep(mdelay)
+ mtries -= 1
+ mdelay *= backoff
+ return f(*args, **kwargs)
+ return f_retry
+ return deco_retry
+
+
# Snippet from http://bugs.python.org/issue9584
def expand_braces(orig):
r = r'.*(\{.+?[^\\]\})'
diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 2537ab4..0cedac4 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -7,6 +7,7 @@ import optparse
import os.path
import random
import re
+import socket
import subprocess
import xmlrpc.client
@@ -14,7 +15,7 @@ from portage.package.ebuild.getmaskingstatus import getmaskingstatus
from portage.xml.metadata import MetaDataXML
import portage.versions
-from common import login
+from common import login, retry
if __name__ == "__main__":
parser = optparse.OptionParser()
@@ -139,19 +140,26 @@ if __name__ == "__main__":
continue
# Do not risk trying to stabilize a package with known bugs.
- params = {}
- params['Bugzilla_token'] = login_data['token']
- params['summary'] = cp
- bugs = [x for x in bugzilla.Bug.search(params)['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+ @retry(socket.error)
+ def get_package_bugs():
+ params = {}
+ params['Bugzilla_token'] = login_data['token']
+ params['summary'] = cp
+ return [x for x in bugzilla.Bug.search(params)['bugs']
+ if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+ bugs = get_package_bugs()
if bugs:
print('has bugs')
continue
# Protection against filing a stabilization bug twice.
- params = {}
- params['Bugzilla_token'] = login_data['token']
- params['summary'] = best_candidate
- bugs = bugzilla.Bug.search(params)['bugs']
+ @retry(socket.error)
+ def get_package_bugs():
+ params = {}
+ params['Bugzilla_token'] = login_data['token']
+ params['summary'] = best_candidate
+ return bugzilla.Bug.search(params)['bugs']
+ bugs = get_package_bugs()
if bugs:
print('version has bugs')
continue