Kaydet (Commit) fdb747ff authored tarafından Michael Stahl's avatar Michael Stahl

get-bugzilla-attachments-by-mimetype: more Python 3 in exception handler

... and also fix the print functions that shouldn't output a newline.

Change-Id: Ifd866cb33b3ef9a2e83625ed03d5cb836c1ba56b
üst 5181dc02
......@@ -18,6 +18,7 @@
#
#where X is the n'th attachment of that type in the bug
from __future__ import print_function
import feedparser
import base64
import re
......@@ -40,7 +41,7 @@ def urlopen_retry(url):
try:
return urlopen(url)
except IOError as e:
print("caught IOError: " + e)
print("caught IOError: " + str(e))
if maxretries == i:
raise
print("retrying...")
......@@ -51,17 +52,17 @@ def get_from_bug_url_via_xml(url, mimetype, prefix, suffix):
if os.path.isfile(suffix + '/' + prefix + id + '-1.' + suffix):
print("assuming " + id + " is up to date")
else:
print("parsing", id)
print("parsing " + id)
sock = urlopen_retry(url+"&ctype=xml")
dom = minidom.parse(sock)
sock.close()
attachmentid=0
for attachment in dom.getElementsByTagName('attachment'):
attachmentid += 1
print(" mimetype is")
print(" mimetype is", end=' ')
for node in attachment.childNodes:
if node.nodeName == 'type':
print(node.firstChild.nodeValue)
print(node.firstChild.nodeValue, end=' ')
if node.firstChild.nodeValue.lower() != mimetype.lower():
print('skipping')
break
......@@ -102,14 +103,14 @@ def get_novell_bug_via_xml(url, mimetype, prefix, suffix):
if not handle:
print("attachment %s is not accessible" % realAttachmentId)
continue
print(" mimetype is")
print(" mimetype is", end=' ')
info = handle.info()
if info.get_content_type:
remoteMime = info.get_content_type()
else:
remoteMime = info.gettype()
print(remoteMime)
print(remoteMime, end=' ')
if remoteMime != mimetype:
print("skipping")
continue
......@@ -161,7 +162,7 @@ def get_through_rss_query_url(url, mimetype, prefix, suffix):
except KeyboardInterrupt:
raise # Ctrl+C should work
except:
print(entry['id'] + " failed: " + sys.exc_info()[0])
print(entry['id'] + " failed: " + str(sys.exc_info()[0]))
pass
def get_through_rss_query(queryurl, mimetype, prefix, suffix):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment