public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Paweł Hajdan" <phajdan.jr@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/arch-tools:master commit in: /
Date: Mon, 10 Jul 2017 20:29:22 +0000 (UTC)	[thread overview]
Message-ID: <1499718530.064b7b3dbf4277b9c57add479a478386504fc0d2.phajdan.jr@gentoo> (raw)

commit:     064b7b3dbf4277b9c57add479a478386504fc0d2
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 10 20:28:50 2017 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Jul 10 20:28:50 2017 +0000
URL:        https://gitweb.gentoo.org/proj/arch-tools.git/commit/?id=064b7b3d

stabilization-candidates: retry network errors

 common.py                   | 19 +++++++++++++++++++
 stabilization-candidates.py | 26 +++++++++++++++++---------
 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


             reply	other threads:[~2017-07-10 20:29 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 20:29 Paweł Hajdan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-07-09 14:42 [gentoo-commits] proj/arch-tools:master commit in: / Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2014-06-14  9:47 Paweł Hajdan
2014-04-07 12:40 Samuli Suominen
2014-02-12  7:06 Paweł Hajdan
2013-06-22 15:05 Paweł Hajdan
2013-06-22 14:57 Paweł Hajdan
2013-05-19 23:35 Paweł Hajdan
2013-03-11 21:56 Paweł Hajdan
2013-02-28  4:50 Paweł Hajdan
2013-02-28  4:50 Paweł Hajdan
2012-10-16 16:54 Paweł Hajdan
2012-10-16 16:54 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:02 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-08-01 11:08 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-08-01  7:28 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-06-04  9:18 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-03-27 15:26 Paweł Hajdan
2012-03-09 11:49 Paweł Hajdan
2012-03-09 11:49 Paweł Hajdan
2012-02-02 16:48 Paweł Hajdan
2012-01-27 14:55 Paweł Hajdan
2012-01-21 17:05 Paweł Hajdan
2011-12-14  7:23 Paweł Hajdan
2011-12-06 11:14 Paweł Hajdan
2011-12-01 18:56 Paweł Hajdan
2011-12-01 18:47 Paweł Hajdan
2011-12-01 18:47 Paweł Hajdan
2011-11-30 17:38 Paweł Hajdan
2011-11-23  8:59 Paweł Hajdan
2011-11-23  8:59 Paweł Hajdan
2011-11-21  8:34 Paweł Hajdan
2011-11-03 11:00 Paweł Hajdan
2011-10-22  8:18 Paweł Hajdan
2011-10-21 15:15 Paweł Hajdan
2011-10-18 14:05 Paweł Hajdan
2011-10-16  3:51 Paweł Hajdan
2011-10-13 21:59 Paweł Hajdan
2011-10-04 21:46 Paweł Hajdan
2011-09-19  3:09 Paweł Hajdan
2011-08-07  3:26 Paweł Hajdan
2011-06-05 16:16 Paweł Hajdan
2011-06-02 15:41 Paweł Hajdan
2011-06-02 15:38 Paweł Hajdan
2011-05-25 19:51 Paweł Hajdan
2011-05-25 10:32 Paweł Hajdan
2011-05-22 15:31 Paweł Hajdan
2011-05-22 15:16 Paweł Hajdan
2011-05-22 13:36 Paweł Hajdan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1499718530.064b7b3dbf4277b9c57add479a478386504fc0d2.phajdan.jr@gentoo \
    --to=phajdan.jr@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox