summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-02-12 21:52:24 +0100
committerMichael Stahl <mstahl@redhat.com>2012-02-13 00:25:03 +0100
commit82259f2e5446fbaaf5921a2cf195faa824629ea3 (patch)
treefd80eeb81bd8e9f54ff25893301412a01a105519 /bin
parent18d1e1968c9bd62b68b447f8a882e37ff3d3dde4 (diff)
get-bugzilla-attachments-by-mimetype: add retry:
Sadly the Apache OO bugzilla is rather unreliable and connections time out a lot; retry connections to work around that.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get-bugzilla-attachments-by-mimetype15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/get-bugzilla-attachments-by-mimetype b/bin/get-bugzilla-attachments-by-mimetype
index 3e52ad654cc3..441049802b1b 100755
--- a/bin/get-bugzilla-attachments-by-mimetype
+++ b/bin/get-bugzilla-attachments-by-mimetype
@@ -44,6 +44,17 @@ import xmlrpclib
from xml.dom import minidom
from xml.sax.saxutils import escape
+def urlopen_retry(url):
+ maxretries = 3
+ for i in range(maxretries + 1):
+ try:
+ return urllib.urlopen(url)
+ except IOError as e:
+ print "caught IOError: ", e
+ if maxretries == i:
+ raise
+ print "retrying..."
+
def get_from_bug_url_via_xml(url, mimetype, prefix, suffix):
id = url.rsplit('=', 2)[1]
print "id is", prefix, id, suffix
@@ -51,12 +62,12 @@ def get_from_bug_url_via_xml(url, mimetype, prefix, suffix):
print "assuming", id, "is up to date"
else:
print "parsing", id
- sock = urllib.urlopen(url+"&ctype=xml")
+ sock = urlopen_retry(url+"&ctype=xml")
dom = minidom.parse(sock)
sock.close()
attachmentid=1
for attachment in dom.getElementsByTagName('attachment'):
- print " mimetype is",
+ print " mimetype is",
for node in attachment.childNodes:
if node.nodeName == 'type':
print node.firstChild.nodeValue,