diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-02-12 21:52:24 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-02-13 00:25:03 +0100 |
commit | 82259f2e5446fbaaf5921a2cf195faa824629ea3 (patch) | |
tree | fd80eeb81bd8e9f54ff25893301412a01a105519 /bin/get-bugzilla-attachments-by-mimetype | |
parent | get-bugzilla-attachments-by-mimetype: don't do images: (diff) | |
download | core-82259f2e5446fbaaf5921a2cf195faa824629ea3.tar.gz core-82259f2e5446fbaaf5921a2cf195faa824629ea3.zip |
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/get-bugzilla-attachments-by-mimetype')
-rwxr-xr-x | bin/get-bugzilla-attachments-by-mimetype | 15 |
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, |