1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-23 14:48:53 +02:00

python3 compatibility: except

changes 'except FooError, fe' to 'except FooError as fe'

available in python 2.6
This commit is contained in:
Michal Vyskocil
2013-04-09 11:27:02 +02:00
committed by Adrian Schröter
parent d3648be24b
commit 3a93ac6d10
16 changed files with 110 additions and 110 deletions

View File

@@ -74,17 +74,17 @@ def run(prg):
except oscerr.UserAbort: except oscerr.UserAbort:
print >>sys.stderr, 'aborted.' print >>sys.stderr, 'aborted.'
return 1 return 1
except oscerr.APIError, e: except oscerr.APIError as e:
print >>sys.stderr, 'BuildService API error:', e.msg print >>sys.stderr, 'BuildService API error:', e.msg
return 1 return 1
except oscerr.LinkExpandError, e: except oscerr.LinkExpandError as e:
print >>sys.stderr, 'Link "%s/%s" cannot be expanded:\n' % (e.prj, e.pac), e.msg print >>sys.stderr, 'Link "%s/%s" cannot be expanded:\n' % (e.prj, e.pac), e.msg
print >>sys.stderr, 'Use "osc repairlink" to fix merge conflicts.\n' print >>sys.stderr, 'Use "osc repairlink" to fix merge conflicts.\n'
return 1 return 1
except oscerr.WorkingCopyWrongVersion, e: except oscerr.WorkingCopyWrongVersion as e:
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except oscerr.NoWorkingCopy, e: except oscerr.NoWorkingCopy as e:
print >>sys.stderr, e print >>sys.stderr, e
if os.path.isdir('.git'): if os.path.isdir('.git'):
print >>sys.stderr, "Current directory looks like git." print >>sys.stderr, "Current directory looks like git."
@@ -95,7 +95,7 @@ def run(prg):
if os.path.isdir('CVS'): if os.path.isdir('CVS'):
print >>sys.stderr, "Current directory looks like cvs." print >>sys.stderr, "Current directory looks like cvs."
return 1 return 1
except HTTPError, e: except HTTPError as e:
print >>sys.stderr, 'Server returned an error:', e print >>sys.stderr, 'Server returned an error:', e
if hasattr(e, 'osc_msg'): if hasattr(e, 'osc_msg'):
print >>sys.stderr, e.osc_msg print >>sys.stderr, e.osc_msg
@@ -116,76 +116,76 @@ def run(prg):
msg = msg.split('</summary>')[0] msg = msg.split('</summary>')[0]
print >>sys.stderr, msg print >>sys.stderr, msg
return 1 return 1
except BadStatusLine, e: except BadStatusLine as e:
print >>sys.stderr, 'Server returned an invalid response:', e print >>sys.stderr, 'Server returned an invalid response:', e
print >>sys.stderr, e.line print >>sys.stderr, e.line
return 1 return 1
except HTTPException, e: except HTTPException as e:
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except URLError, e: except URLError as e:
print >>sys.stderr, 'Failed to reach a server:\n', e.reason print >>sys.stderr, 'Failed to reach a server:\n', e.reason
return 1 return 1
except IOError, e: except IOError as e:
# ignore broken pipe # ignore broken pipe
if e.errno != errno.EPIPE: if e.errno != errno.EPIPE:
raise raise
return 1 return 1
except OSError, e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except (oscerr.ConfigError, oscerr.NoConfigfile), e: except (oscerr.ConfigError, oscerr.NoConfigfile) as e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
return 1 return 1
except oscerr.OscIOError, e: except oscerr.OscIOError as e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
if getattr(prg.options, 'debug', None) or \ if getattr(prg.options, 'debug', None) or \
getattr(prg.conf, 'config', {}).get('debug', None): getattr(prg.conf, 'config', {}).get('debug', None):
print >>sys.stderr, e.e print >>sys.stderr, e.e
return 1 return 1
except (oscerr.WrongOptions, oscerr.WrongArgs), e: except (oscerr.WrongOptions, oscerr.WrongArgs) as e:
print >>sys.stderr, e print >>sys.stderr, e
return 2 return 2
except oscerr.ExtRuntimeError, e: except oscerr.ExtRuntimeError as e:
print >>sys.stderr, e.file + ':', e.msg print >>sys.stderr, e.file + ':', e.msg
return 1 return 1
except oscerr.WorkingCopyOutdated, e: except oscerr.WorkingCopyOutdated as e:
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except (oscerr.PackageExists, oscerr.PackageMissing, oscerr.WorkingCopyInconsistent), e: except (oscerr.PackageExists, oscerr.PackageMissing, oscerr.WorkingCopyInconsistent) as e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
return 1 return 1
except oscerr.PackageInternalError, e: except oscerr.PackageInternalError as e:
print >>sys.stderr, 'a package internal error occured\n' \ print >>sys.stderr, 'a package internal error occured\n' \
'please file a bug and attach your current package working copy ' \ 'please file a bug and attach your current package working copy ' \
'and the following traceback to it:' 'and the following traceback to it:'
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
traceback.print_exc(file=sys.stderr) traceback.print_exc(file=sys.stderr)
return 1 return 1
except oscerr.PackageError, e: except oscerr.PackageError as e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
return 1 return 1
except PackageError, e: except PackageError as e:
print >>sys.stderr, '%s:' % e.fname, e.msg print >>sys.stderr, '%s:' % e.fname, e.msg
return 1 return 1
except RPMError, e: except RPMError as e:
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except SSLError, e: except SSLError as e:
print >>sys.stderr, "SSL Error:", e print >>sys.stderr, "SSL Error:", e
return 1 return 1
except SSLVerificationError, e: except SSLVerificationError as e:
print >>sys.stderr, "Certificate Verification Error:", e print >>sys.stderr, "Certificate Verification Error:", e
return 1 return 1
except NoSecureSSLError, e: except NoSecureSSLError as e:
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except CpioError, e: except CpioError as e:
print >>sys.stderr, e print >>sys.stderr, e
return 1 return 1
except oscerr.OscBaseError, e: except oscerr.OscBaseError as e:
print >>sys.stderr, '*** Error:', e print >>sys.stderr, '*** Error:', e
return 1 return 1

View File

@@ -605,7 +605,7 @@ def main(apiurl, opts, argv):
bc_file = open(bc_filename, 'w') bc_file = open(bc_filename, 'w')
bc_file.write(bc) bc_file.write(bc)
bc_file.flush() bc_file.flush()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
# check what caused the 404 # check what caused the 404
if meta_exists(metatype='prj', path_args=(quote_plus(prj), ), if meta_exists(metatype='prj', path_args=(quote_plus(prj), ),
@@ -728,7 +728,7 @@ def main(apiurl, opts, argv):
try: try:
print "Downloading previous build from %s ..." % '/'.join(data) print "Downloading previous build from %s ..." % '/'.join(data)
binaries = get_binarylist(apiurl, data[0], data[2], data[3], package=data[1], verbose=True) binaries = get_binarylist(apiurl, data[0], data[2], data[3], package=data[1], verbose=True)
except Exception, e: except Exception as e:
print "Error: failed to get binaries: %s" % str(e) print "Error: failed to get binaries: %s" % str(e)
binaries = [] binaries = []
@@ -914,7 +914,7 @@ def main(apiurl, opts, argv):
print print
print 'The buildroot was:', build_root print 'The buildroot was:', build_root
sys.exit(rc) sys.exit(rc)
except KeyboardInterrupt, i: except KeyboardInterrupt as i:
print "keyboard interrupt, killing build ..." print "keyboard interrupt, killing build ..."
cmd.append('--kill') cmd.append('--kill')
run_external(cmd[0], *cmd[1:]) run_external(cmd[0], *cmd[1:])

View File

@@ -28,7 +28,7 @@ class Checker:
for key in keys: for key in keys:
try: try:
self.readkey(key) self.readkey(key)
except KeyError, e: except KeyError as e:
print e print e
if not len(self.imported): if not len(self.imported):
@@ -108,7 +108,7 @@ if __name__ == "__main__":
checker.readkeys(keyfiles) checker.readkeys(keyfiles)
for pkg in pkgs: for pkg in pkgs:
checker.check(pkg) checker.check(pkg)
except Exception, e: except Exception as e:
checker.cleanup() checker.cleanup()
raise e raise e

View File

@@ -289,13 +289,13 @@ class RawCmdln(cmd.Cmd):
if self.optparser: # i.e. optparser=None means don't process for opts if self.optparser: # i.e. optparser=None means don't process for opts
try: try:
self.options, args = self.optparser.parse_args(argv[1:]) self.options, args = self.optparser.parse_args(argv[1:])
except CmdlnUserError, ex: except CmdlnUserError as ex:
msg = "%s: %s\nTry '%s help' for info.\n"\ msg = "%s: %s\nTry '%s help' for info.\n"\
% (self.name, ex, self.name) % (self.name, ex, self.name)
self.stderr.write(self._str(msg)) self.stderr.write(self._str(msg))
self.stderr.flush() self.stderr.flush()
return 1 return 1
except StopOptionProcessing, ex: except StopOptionProcessing as ex:
return 0 return 0
else: else:
self.options, args = None, argv[1:] self.options, args = None, argv[1:]
@@ -1174,7 +1174,7 @@ class Cmdln(RawCmdln):
try: try:
return handler(argv[0], opts, *args) return handler(argv[0], opts, *args)
except TypeError, ex: except TypeError as ex:
# Some TypeError's are user errors: # Some TypeError's are user errors:
# do_foo() takes at least 4 arguments (3 given) # do_foo() takes at least 4 arguments (3 given)
# do_foo() takes at most 5 arguments (6 given) # do_foo() takes at most 5 arguments (6 given)

View File

@@ -120,7 +120,7 @@ class Osc(cmdln.Cmdln):
override_no_keyring = self.options.no_keyring, override_no_keyring = self.options.no_keyring,
override_no_gnome_keyring = self.options.no_gnome_keyring, override_no_gnome_keyring = self.options.no_gnome_keyring,
override_verbose = self.options.verbose) override_verbose = self.options.verbose)
except oscerr.NoConfigfile, e: except oscerr.NoConfigfile as e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
print >>sys.stderr, 'Creating osc configuration file %s ...' % e.file print >>sys.stderr, 'Creating osc configuration file %s ...' % e.file
import getpass import getpass
@@ -137,7 +137,7 @@ class Osc(cmdln.Cmdln):
conf.write_initial_config(e.file, config) conf.write_initial_config(e.file, config)
print >>sys.stderr, 'done' print >>sys.stderr, 'done'
if try_again: self.postoptparse(try_again = False) if try_again: self.postoptparse(try_again = False)
except oscerr.ConfigMissingApiurl, e: except oscerr.ConfigMissingApiurl as e:
print >>sys.stderr, e.msg print >>sys.stderr, e.msg
import getpass import getpass
user = raw_input('Username: ') user = raw_input('Username: ')
@@ -162,10 +162,10 @@ class Osc(cmdln.Cmdln):
def get_api_url(self): def get_api_url(self):
try: try:
localdir = os.getcwd() localdir = os.getcwd()
except Exception, e: except Exception as e:
## check for Stale NFS file handle: '.' ## check for Stale NFS file handle: '.'
try: os.stat('.') try: os.stat('.')
except Exception, ee: e = ee except Exception as ee: e = ee
print >>sys.stderr, "os.getcwd() failed: ", e print >>sys.stderr, "os.getcwd() failed: ", e
sys.exit(1) sys.exit(1)
@@ -2091,7 +2091,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
try: try:
# works since OBS 2.1 # works since OBS 2.1
diff = request_diff(apiurl, reqid) diff = request_diff(apiurl, reqid)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
# for OBS 2.0 and before # for OBS 2.0 and before
sr_actions = r.get_actions('submit') sr_actions = r.get_actions('submit')
if not sr_actions: if not sr_actions:
@@ -2132,7 +2132,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
r = change_review_state(apiurl, reqid, state_map[cmd], review.by_user, review.by_group, r = change_review_state(apiurl, reqid, state_map[cmd], review.by_user, review.by_group,
review.by_project, review.by_package, opts.message or '', supersed=supersedid) review.by_project, review.by_package, opts.message or '', supersed=supersedid)
print r print r
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if review.by_user: if review.by_user:
print 'No permission on review by user %s' % review.by_user print 'No permission on review by user %s' % review.by_user
if review.by_group: if review.by_group:
@@ -2189,10 +2189,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if link_node != None: if link_node != None:
links_to_project = link_node.get('project') or project links_to_project = link_node.get('project') or project
links_to_package = link_node.get('package') or package links_to_package = link_node.get('package') or package
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
print >>sys.stderr, 'Cannot get list of files for %s/%s: %s' % (project, package, e) print >>sys.stderr, 'Cannot get list of files for %s/%s: %s' % (project, package, e)
except SyntaxError, e: except SyntaxError as e:
print >>sys.stderr, 'Cannot parse list of files for %s/%s: %s' % (project, package, e) print >>sys.stderr, 'Cannot parse list of files for %s/%s: %s' % (project, package, e)
if links_to_project==action.tgt_project and links_to_package==action.tgt_package: if links_to_project==action.tgt_project and links_to_package==action.tgt_package:
# links to my request target anyway, no need to forward submit # links to my request target anyway, no need to forward submit
@@ -2359,7 +2359,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
try: try:
copy_pac(apiurl, project, package, apiurl, project, package, expand=True, comment=opts.message) copy_pac(apiurl, project, package, apiurl, project, package, expand=True, comment=opts.message)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
root = ET.fromstring(show_files_meta(apiurl, project, package, 'latest', expand=False)) root = ET.fromstring(show_files_meta(apiurl, project, package, 'latest', expand=False))
li = Linkinfo() li = Linkinfo()
li.read(root.find('linkinfo')) li.read(root.find('linkinfo'))
@@ -2955,7 +2955,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
uproject = root.find('attribute').find('value').text uproject = root.find('attribute').find('value').text
print '\nNote: The branch has been created from the configured update project: %s' \ print '\nNote: The branch has been created from the configured update project: %s' \
% uproject % uproject
except (AttributeError, urllib2.HTTPError), e: except (AttributeError, urllib2.HTTPError) as e:
devloc = srcprj devloc = srcprj
print '\nNote: The branch has been created of a different project,\n' \ print '\nNote: The branch has been created of a different project,\n' \
' %s,\n' \ ' %s,\n' \
@@ -3373,7 +3373,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
try: try:
show_package_meta(apiurl, project, package) show_package_meta(apiurl, project, package)
return True return True
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
print >>sys.stderr, 'Cannot check that %s/%s exists: %s' % (project, package, e) print >>sys.stderr, 'Cannot check that %s/%s exists: %s' % (project, package, e)
return False return False
@@ -3401,9 +3401,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
try: try:
file = http_GET(link_url) file = http_GET(link_url)
root = ET.parse(file).getroot() root = ET.parse(file).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
return (None, None) return (None, None)
except SyntaxError, e: except SyntaxError as e:
print >>sys.stderr, 'Cannot parse %s/%s/_link: %s' % (project, package, e) print >>sys.stderr, 'Cannot parse %s/%s/_link: %s' % (project, package, e)
return (None, None) return (None, None)
@@ -3420,11 +3420,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
try: try:
file = http_GET(link_url) file = http_GET(link_url)
root = ET.parse(file).getroot() root = ET.parse(file).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
print >>sys.stderr, 'Cannot get list of files for %s/%s: %s' % (project, package, e) print >>sys.stderr, 'Cannot get list of files for %s/%s: %s' % (project, package, e)
return (None, None, None) return (None, None, None)
except SyntaxError, e: except SyntaxError as e:
print >>sys.stderr, 'Cannot parse list of files for %s/%s: %s' % (project, package, e) print >>sys.stderr, 'Cannot parse list of files for %s/%s: %s' % (project, package, e)
return (None, None, None) return (None, None, None)
@@ -3864,7 +3864,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
try: try:
checkout_package(apiurl, project, package, expand_link = expand_link, \ checkout_package(apiurl, project, package, expand_link = expand_link, \
prj_dir = prj_dir, service_files = opts.source_service_files, server_service_files = opts.server_side_source_service_files, progress_obj=self.download_progress, size_limit=opts.limit_size, meta=opts.meta) prj_dir = prj_dir, service_files = opts.source_service_files, server_service_files = opts.server_side_source_service_files, progress_obj=self.download_progress, size_limit=opts.limit_size, meta=opts.meta)
except oscerr.LinkExpandError, e: except oscerr.LinkExpandError as e:
print >>sys.stderr, 'Link cannot be expanded:\n', e print >>sys.stderr, 'Link cannot be expanded:\n', e
print >>sys.stderr, 'Use "osc repairlink" for fixing merge conflicts:\n' print >>sys.stderr, 'Use "osc repairlink" for fixing merge conflicts:\n'
# check out in unexpanded form at least # check out in unexpanded form at least
@@ -4108,7 +4108,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not msg: if not msg:
msg = edit_message() msg = edit_message()
prj.commit(msg=msg, skip_local_service_run=skip_local_service_run, verbose=opts.verbose) prj.commit(msg=msg, skip_local_service_run=skip_local_service_run, verbose=opts.verbose)
except oscerr.ExtRuntimeError, e: except oscerr.ExtRuntimeError as e:
print >>sys.stderr, "ERROR: service run failed", e print >>sys.stderr, "ERROR: service run failed", e
return 1 return 1
args.remove(arg) args.remove(arg)
@@ -4441,7 +4441,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
continue continue
try: try:
delete_files(apiurl, project, package, (filename, )) delete_files(apiurl, project, package, (filename, ))
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if opts.force: if opts.force:
print >>sys.stderr, e print >>sys.stderr, e
body = e.read() body = e.read()
@@ -6283,7 +6283,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print r.list_view(), '\n' print r.list_view(), '\n'
print "" print ""
return return
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 400: if e.code == 400:
# skip it ... try again with old style below # skip it ... try again with old style below
pass pass
@@ -6478,7 +6478,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
what = {'published/binary/id': xpath} what = {'published/binary/id': xpath}
try: try:
res = search(apiurl, **what) res = search(apiurl, **what)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 400 or not role_filter: if e.code != 400 or not role_filter:
raise e raise e
# backward compatibility: local role filtering # backward compatibility: local role filtering
@@ -6881,7 +6881,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for role in roles: for role in roles:
try: try:
setBugowner(apiurl, result.get('project'), result.get('package'), bugowner) setBugowner(apiurl, result.get('project'), result.get('package'), bugowner)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 403: if e.code == 403:
print "No write permission in", result.get('project'), print "No write permission in", result.get('project'),
if result.get('package'): if result.get('package'):
@@ -6904,7 +6904,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for role in roles: for role in roles:
try: try:
setBugowner(apiurl, prj, pac, opts.delete, role) setBugowner(apiurl, prj, pac, opts.delete, role)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 403: if e.code == 403:
print "No write permission in", result.get('project'), print "No write permission in", result.get('project'),
if result.get('package'): if result.get('package'):
@@ -7108,7 +7108,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else: else:
for data in streamfile(u): for data in streamfile(u):
sys.stdout.write(data) sys.stdout.write(data)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404 and not opts.expand and not opts.unexpand: if e.code == 404 and not opts.expand and not opts.unexpand:
print >>sys.stderr, 'expanding link...' print >>sys.stderr, 'expanding link...'
query['rev'] = show_upstream_srcmd5(apiurl, args[0], args[1], expand=True, revision=opts.revision) query['rev'] = show_upstream_srcmd5(apiurl, args[0], args[1], expand=True, revision=opts.revision)
@@ -7527,7 +7527,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
url = makeurl(apiurl, ['source', prj, '_pubkey']) url = makeurl(apiurl, ['source', prj, '_pubkey'])
f = http_GET(url) f = http_GET(url)
break break
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
l = prj.rsplit(':', 1) l = prj.rsplit(':', 1)
# try key from parent project # try key from parent project
if not opts.notraverse and len(l) > 1 and l[0] and l[1] and e.code == 404: if not opts.notraverse and len(l) > 1 and l[0] and l[1] and e.code == 404:
@@ -7797,7 +7797,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if is_project_dir(i): if is_project_dir(i):
try: try:
prj = Project(i, getPackageList=False) prj = Project(i, getPackageList=False)
except oscerr.WorkingCopyInconsistent, e: except oscerr.WorkingCopyInconsistent as e:
if '_apiurl' in e.dirty_files and (not apiurl or not opts.force_apiurl): if '_apiurl' in e.dirty_files and (not apiurl or not opts.force_apiurl):
apiurl = get_apiurl(apiurls) apiurl = get_apiurl(apiurls)
prj = Project(i, getPackageList=False, wc_check=False) prj = Project(i, getPackageList=False, wc_check=False)
@@ -7817,7 +7817,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for pdir in pacs: for pdir in pacs:
try: try:
p = Package(pdir) p = Package(pdir)
except oscerr.WorkingCopyInconsistent, e: except oscerr.WorkingCopyInconsistent as e:
if '_apiurl' in e.dirty_files and (not apiurl or not opts.force_apiurl): if '_apiurl' in e.dirty_files and (not apiurl or not opts.force_apiurl):
apiurl = get_apiurl(apiurls) apiurl = get_apiurl(apiurls)
p = Package(pdir, wc_check=False) p = Package(pdir, wc_check=False)
@@ -7841,7 +7841,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
continue continue
try: try:
exec open(os.path.join(plugin_dir, extfile)) exec open(os.path.join(plugin_dir, extfile))
except SyntaxError, e: except SyntaxError as e:
if (os.environ.get('OSC_PLUGIN_FAIL_IGNORE')): if (os.environ.get('OSC_PLUGIN_FAIL_IGNORE')):
print >>sys.stderr, "%s: %s\n" % (plugin_dir, e) print >>sys.stderr, "%s: %s\n" % (plugin_dir, e)
else: else:

View File

@@ -77,7 +77,7 @@ def _get_processors():
""" """
try: try:
return os.sysconf('SC_NPROCESSORS_ONLN') return os.sysconf('SC_NPROCESSORS_ONLN')
except ValueError, e: except ValueError as e:
return 1 return 1
DEFAULTS = {'apiurl': 'https://api.opensuse.org', DEFAULTS = {'apiurl': 'https://api.opensuse.org',
@@ -482,7 +482,7 @@ def _build_opener(url):
try: try:
import oscssl import oscssl
from M2Crypto import m2urllib2 from M2Crypto import m2urllib2
except ImportError, e: except ImportError as e:
print e print e
raise NoSecureSSLError('M2Crypto is needed to access %s in a secure way.\nPlease install python-m2crypto.' % apiurl) raise NoSecureSSLError('M2Crypto is needed to access %s in a secure way.\nPlease install python-m2crypto.' % apiurl)
@@ -766,7 +766,7 @@ def get_config(override_conffile=None,
for i in boolean_opts: for i in boolean_opts:
try: try:
config[i] = cp.getboolean('general', i) config[i] = cp.getboolean('general', i)
except ValueError, e: except ValueError as e:
raise oscerr.ConfigError('cannot parse \'%s\' setting: ' % i + str(e), conffile) raise oscerr.ConfigError('cannot parse \'%s\' setting: ' % i + str(e), conffile)
config['packagecachedir'] = os.path.expanduser(config['packagecachedir']) config['packagecachedir'] = os.path.expanduser(config['packagecachedir'])
@@ -949,7 +949,7 @@ def get_config(override_conffile=None,
# provided that there _are_ credentials for the chosen apiurl: # provided that there _are_ credentials for the chosen apiurl:
try: try:
config['user'] = get_apiurl_usr(config['apiurl']) config['user'] = get_apiurl_usr(config['apiurl'])
except oscerr.ConfigMissingApiurl, e: except oscerr.ConfigMissingApiurl as e:
e.msg = config_missing_apiurl_text % config['apiurl'] e.msg = config_missing_apiurl_text % config['apiurl']
e.file = conffile e.file = conffile
raise e raise e

View File

@@ -276,7 +276,7 @@ class Serviceinfo:
self.read(root, True) self.read(root, True)
self.project = project self.project = project
self.package = package self.package = package
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 403 and e.code != 400: if e.code != 403 and e.code != 400:
raise e raise e
@@ -1104,7 +1104,7 @@ class Package:
state = '?' state = '?'
try: try:
state = self.status(n) state = self.status(n)
except IOError, ioe: except IOError as ioe:
if not force: if not force:
raise ioe raise ioe
if state in ['?', 'A', 'M', 'R', 'C'] and not force: if state in ['?', 'A', 'M', 'R', 'C'] and not force:
@@ -2763,7 +2763,7 @@ def read_filemeta(dir):
try: try:
r = ET.parse(filesmeta) r = ET.parse(filesmeta)
except SyntaxError, e: except SyntaxError as e:
raise oscerr.NoWorkingCopy('%s\nWhen parsing .osc/_files, the following error was encountered:\n%s' % (msg, e)) raise oscerr.NoWorkingCopy('%s\nWhen parsing .osc/_files, the following error was encountered:\n%s' % (msg, e))
return r return r
@@ -2888,7 +2888,7 @@ def http_request(method, url, headers={}, data=None, file=None, timeout=100):
else: else:
data = mmap.mmap(filefd.fileno(), os.path.getsize(file)) data = mmap.mmap(filefd.fileno(), os.path.getsize(file))
data = memoryview(data) data = memoryview(data)
except EnvironmentError, e: except EnvironmentError as e:
if e.errno == 19: if e.errno == 19:
sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \ sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \
'\non a filesystem which does not support this.' % (e, file)) '\non a filesystem which does not support this.' % (e, file))
@@ -3026,7 +3026,7 @@ def show_package_trigger_reason(apiurl, prj, pac, repo, arch):
try: try:
f = http_GET(url) f = http_GET(url)
return f.read() return f.read()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'Error getting trigger reason for project \'%s\' package \'%s\'' % (prj, pac) e.osc_msg = 'Error getting trigger reason for project \'%s\' package \'%s\'' % (prj, pac)
raise raise
@@ -3044,7 +3044,7 @@ def show_package_meta(apiurl, prj, pac, meta=False):
try: try:
f = http_GET(url) f = http_GET(url)
return f.readlines() return f.readlines()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (prj, pac) e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (prj, pac)
raise raise
@@ -3069,7 +3069,7 @@ def show_attribute_meta(apiurl, prj, pac, subpac, attribute, with_defaults, with
try: try:
f = http_GET(url) f = http_GET(url)
return f.readlines() return f.readlines()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (prj, pac) e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (prj, pac)
raise raise
@@ -3101,7 +3101,7 @@ def show_pattern_metalist(apiurl, prj):
try: try:
f = http_GET(url) f = http_GET(url)
tree = ET.parse(f) tree = ET.parse(f)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'show_pattern_metalist: Error getting pattern list for project \'%s\'' % prj e.osc_msg = 'show_pattern_metalist: Error getting pattern list for project \'%s\'' % prj
raise raise
r = [ node.get('name') for node in tree.getroot() ] r = [ node.get('name') for node in tree.getroot() ]
@@ -3114,7 +3114,7 @@ def show_pattern_meta(apiurl, prj, pattern):
try: try:
f = http_GET(url) f = http_GET(url)
return f.readlines() return f.readlines()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'show_pattern_meta: Error getting pattern \'%s\' for project \'%s\'' % (pattern, prj) e.osc_msg = 'show_pattern_meta: Error getting pattern \'%s\' for project \'%s\'' % (pattern, prj)
raise raise
@@ -3152,7 +3152,7 @@ class metafile:
try: try:
self.sync() self.sync()
break break
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
error_help = "%d" % e.code error_help = "%d" % e.code
if e.headers.get('X-Opensuse-Errorcode'): if e.headers.get('X-Opensuse-Errorcode'):
error_help = "%s (%d)" % (e.headers.get('X-Opensuse-Errorcode'), e.code) error_help = "%s (%d)" % (e.headers.get('X-Opensuse-Errorcode'), e.code)
@@ -3215,7 +3215,7 @@ def meta_exists(metatype,
url = make_meta_url(metatype, path_args, apiurl) url = make_meta_url(metatype, path_args, apiurl)
try: try:
data = http_GET(url).readlines() data = http_GET(url).readlines()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404 and create_new: if e.code == 404 and create_new:
data = metatypes[metatype]['template'] data = metatypes[metatype]['template']
if template_args: if template_args:
@@ -3597,7 +3597,7 @@ def create_submit_request(apiurl,
f = http_POST(u, data=xml) f = http_POST(u, data=xml)
root = ET.parse(f).getroot() root = ET.parse(f).getroot()
r = root.get('id') r = root.get('id')
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.headers.get('X-Opensuse-Errorcode') == "submit_request_rejected": if e.headers.get('X-Opensuse-Errorcode') == "submit_request_rejected":
print "WARNING:" print "WARNING:"
print "WARNING: Project does not accept submit request, request to open a NEW maintenance incident instead" print "WARNING: Project does not accept submit request, request to open a NEW maintenance incident instead"
@@ -3675,7 +3675,7 @@ def change_request_state_template(req, newstate):
'tgt_project': action.tgt_project, 'tgt_package': action.tgt_package}) 'tgt_project': action.tgt_project, 'tgt_package': action.tgt_package})
try: try:
return tmpl % data return tmpl % data
except KeyError, e: except KeyError as e:
print >>sys.stderr, 'error: cannot interpolate \'%s\' in \'%s\'' % (e.args[0], tmpl_name) print >>sys.stderr, 'error: cannot interpolate \'%s\' in \'%s\'' % (e.args[0], tmpl_name)
return '' return ''
@@ -4114,7 +4114,7 @@ def server_diff_noex(apiurl,
old_project, old_package, old_revision, old_project, old_package, old_revision,
new_project, new_package, new_revision, new_project, new_package, new_revision,
unified, missingok, meta, expand) unified, missingok, meta, expand)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
msg = None msg = None
body = None body = None
try: try:
@@ -4152,12 +4152,12 @@ def submit_action_diff(apiurl, action):
try: try:
return server_diff(apiurl, action.tgt_project, action.tgt_package, None, return server_diff(apiurl, action.tgt_project, action.tgt_package, None,
action.src_project, action.src_package, action.src_rev, True, True) action.src_project, action.src_package, action.src_rev, True, True)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 400: if e.code == 400:
try: try:
return server_diff(apiurl, action.tgt_project, action.tgt_package, None, return server_diff(apiurl, action.tgt_project, action.tgt_package, None,
action.src_project, action.src_package, action.src_rev, True, False) action.src_project, action.src_package, action.src_rev, True, False)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
raise e raise e
root = ET.fromstring(e.read()) root = ET.fromstring(e.read())
@@ -4532,7 +4532,7 @@ def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute,
f = None f = None
try: try:
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
msg = ''.join(e.readlines()) msg = ''.join(e.readlines())
msg = msg.split('<summary>')[1] msg = msg.split('<summary>')[1]
msg = msg.split('</summary>')[0] msg = msg.split('</summary>')[0]
@@ -4584,7 +4584,7 @@ def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None,
u = makeurl(apiurl, ['source', src_project, src_package], query=query) u = makeurl(apiurl, ['source', src_project, src_package], query=query)
try: try:
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if not return_existing: if not return_existing:
raise raise
root = ET.fromstring(e.read()) root = ET.fromstring(e.read())
@@ -4635,7 +4635,7 @@ def copy_pac(src_apiurl, src_project, src_package,
found = None found = None
try: try:
found = http_GET(url).readlines() found = http_GET(url).readlines()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
pass pass
if force_meta_update or not found: if force_meta_update or not found:
print 'Sending meta data...' print 'Sending meta data...'
@@ -4919,7 +4919,7 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], ve
results = r = [] results = r = []
try: try:
results = get_package_results(apiurl, prj, package, lastbuild, repository, arch, oldstate) results = get_package_results(apiurl, prj, package, lastbuild, repository, arch, oldstate)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
# check for simple timeout error and fetch again # check for simple timeout error and fetch again
if e.code != 502: if e.code != 502:
raise raise
@@ -5424,7 +5424,7 @@ def runservice(apiurl, prj, package):
try: try:
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'could not trigger service run for project \'%s\' package \'%s\'' % (prj, package) e.osc_msg = 'could not trigger service run for project \'%s\' package \'%s\'' % (prj, package)
raise raise
@@ -5446,7 +5446,7 @@ def rebuild(apiurl, prj, package, repo, arch, code=None):
u = makeurl(apiurl, ['build', prj], query=query) u = makeurl(apiurl, ['build', prj], query=query)
try: try:
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package) e.osc_msg = 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package)
raise raise
@@ -5568,7 +5568,7 @@ def abortbuild(apiurl, project, package=None, arch=None, repo=None):
u = makeurl(apiurl, ['build', project], query) u = makeurl(apiurl, ['build', project], query)
try: try:
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'abortion failed for project %s' % project e.osc_msg = 'abortion failed for project %s' % project
if package: if package:
e.osc_msg += ' package %s' % package e.osc_msg += ' package %s' % package
@@ -5596,7 +5596,7 @@ def wipebinaries(apiurl, project, package=None, arch=None, repo=None, code=None)
u = makeurl(apiurl, ['build', project], query) u = makeurl(apiurl, ['build', project], query)
try: try:
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'wipe binary rpms failed for project %s' % project e.osc_msg = 'wipe binary rpms failed for project %s' % project
if package: if package:
e.osc_msg += ' package %s' % package e.osc_msg += ' package %s' % package
@@ -5782,7 +5782,7 @@ def owner(apiurl, binary, mode="binary", attribute=None, project=None, usefilter
try: try:
f = http_GET(u) f = http_GET(u)
res = ET.parse(f).getroot() res = ET.parse(f).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
# old server not supporting this search # old server not supporting this search
pass pass
return res return res
@@ -5797,7 +5797,7 @@ def set_link_rev(apiurl, project, package, revision='', expand=False, baserev=Fa
try: try:
f = http_GET(url) f = http_GET(url)
root = ET.parse(f).getroot() root = ET.parse(f).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project) e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project)
raise raise
@@ -6295,7 +6295,7 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None, igno
try: try:
change_request_state(*args, **kwargs) change_request_state(*args, **kwargs)
return True return True
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
print >>sys.stderr, 'Server returned an error:', e print >>sys.stderr, 'Server returned an error:', e
print >>sys.stderr, 'Try -f to force the state change' print >>sys.stderr, 'Try -f to force the state change'
return False return False
@@ -6331,7 +6331,7 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None, igno
try: try:
diff = request_diff(apiurl, request.reqid) diff = request_diff(apiurl, request.reqid)
tmpfile.write(diff) tmpfile.write(diff)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 400: if e.code != 400:
raise raise
# backward compatible diff for old apis # backward compatible diff for old apis
@@ -6534,7 +6534,7 @@ def get_user_projpkgs(apiurl, user, role=None, exclude_projects=[], proj=True, p
what['project_id'] = xpath_prj what['project_id'] = xpath_prj
try: try:
res = search(apiurl, **what) res = search(apiurl, **what)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 400 or not role_filter_xpath: if e.code != 400 or not role_filter_xpath:
raise e raise e
# backward compatibility: local role filtering # backward compatibility: local role filtering
@@ -6575,7 +6575,7 @@ def run_external(filename, *args, **kwargs):
cmd = filename cmd = filename
try: try:
return subprocess.call(cmd, **kwargs) return subprocess.call(cmd, **kwargs)
except OSError, e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
raise oscerr.ExtRuntimeError(e.strerror, filename) raise oscerr.ExtRuntimeError(e.strerror, filename)

View File

@@ -43,13 +43,13 @@ class OscFileGrabber:
try: try:
for i in streamfile(url, progress_obj=self.progress_obj, text=text): for i in streamfile(url, progress_obj=self.progress_obj, text=text):
f.write(i) f.write(i)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
exc = URLGrabError(14, str(e)) exc = URLGrabError(14, str(e))
exc.url = url exc.url = url
exc.exception = e exc.exception = e
exc.code = e.code exc.code = e.code
raise exc raise exc
except IOError, e: except IOError as e:
raise URLGrabError(4, str(e)) raise URLGrabError(4, str(e))
finally: finally:
f.close() f.close()
@@ -126,7 +126,7 @@ class Fetcher:
if not os.path.isfile(pac.fullfilename): if not os.path.isfile(pac.fullfilename):
raise oscerr.APIError('failed to fetch file \'%s\': ' \ raise oscerr.APIError('failed to fetch file \'%s\': ' \
'does not exist in CPIO archive' % pac.repofilename) 'does not exist in CPIO archive' % pac.repofilename)
except URLGrabError, e: except URLGrabError as e:
if e.errno != 14 or e.code != 414: if e.errno != 14 or e.code != 414:
raise raise
# query str was too large # query str was too large
@@ -168,7 +168,7 @@ class Fetcher:
filename = tmpfile, filename = tmpfile,
text = '%s(%s) %s' %(prefix, pac.project, pac.filename)) text = '%s(%s) %s' %(prefix, pac.project, pac.filename))
self.move_package(tmpfile, pac.localdir, pac) self.move_package(tmpfile, pac.localdir, pac)
except URLGrabError, e: except URLGrabError as e:
if self.enable_cpio and e.errno == 256: if self.enable_cpio and e.errno == 256:
self.__add_cpio(pac) self.__add_cpio(pac)
return return
@@ -205,7 +205,7 @@ class Fetcher:
if not os.path.exists(dir): if not os.path.exists(dir):
try: try:
os.makedirs(dir, mode=0755) os.makedirs(dir, mode=0755)
except OSError, e: except OSError as e:
print >>sys.stderr, 'packagecachedir is not writable for you?' print >>sys.stderr, 'packagecachedir is not writable for you?'
print >>sys.stderr, e print >>sys.stderr, e
sys.exit(1) sys.exit(1)
@@ -269,7 +269,7 @@ class Fetcher:
if os.path.exists(dest): if os.path.exists(dest):
os.unlink(dest) os.unlink(dest)
sys.exit(0) sys.exit(0)
except URLGrabError, e: except URLGrabError as e:
# Not found is okay, let's go to the next project # Not found is okay, let's go to the next project
if e.code != 404: if e.code != 404:
print >>sys.stderr, "Invalid answer from server", e print >>sys.stderr, "Invalid answer from server", e
@@ -380,7 +380,7 @@ def verify_pacs(bi):
for pkg in pac_list: for pkg in pac_list:
try: try:
checker.check(pkg) checker.check(pkg)
except Exception, e: except Exception as e:
failed = True failed = True
print pkg, ':', e print pkg, ':', e
except: except:

View File

@@ -75,7 +75,7 @@ def verify_cb(ctx, ok, store):
ctx.verrs.record(store.get_current_cert(), store.get_error(), store.get_error_depth()) ctx.verrs.record(store.get_current_cert(), store.get_error(), store.get_error_depth())
return 1 return 1
except Exception, e: except Exception as e:
print e print e
return 0 return 0
@@ -211,7 +211,7 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
if s: if s:
self.saved_session = s self.saved_session = s
r = h.getresponse() r = h.getresponse()
except socket.error, err: # XXX what error? except socket.error as err: # XXX what error?
err.filename = full_url err.filename = full_url
raise M2Crypto.m2urllib2.URLError(err) raise M2Crypto.m2urllib2.URLError(err)

View File

@@ -163,7 +163,7 @@ class Ar:
self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot=mmap.PROT_READ) self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot=mmap.PROT_READ)
else: else:
self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name)) self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name))
except EnvironmentError, e: except EnvironmentError as e:
if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ): if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ):
print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io' print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io'
else: else:

View File

@@ -152,7 +152,7 @@ if __name__ == '__main__':
import sys import sys
try: try:
archq = ArchQuery.query(sys.argv[1]) archq = ArchQuery.query(sys.argv[1])
except ArchError, e: except ArchError as e:
print e.msg print e.msg
sys.exit(2) sys.exit(2)
print archq.name(), archq.version(), archq.release(), archq.arch() print archq.name(), archq.version(), archq.release(), archq.arch()

View File

@@ -150,7 +150,7 @@ class CpioRead:
self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot = mmap.PROT_READ) self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot = mmap.PROT_READ)
else: else:
self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name)) self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name))
except EnvironmentError, e: except EnvironmentError as e:
if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ): if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ):
print >>sys.stderr, 'cannot use mmap to read the file, failing back to default' print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'
else: else:

View File

@@ -167,7 +167,7 @@ if __name__ == '__main__':
import sys import sys
try: try:
debq = DebQuery.query(sys.argv[1]) debq = DebQuery.query(sys.argv[1])
except DebError, e: except DebError as e:
print e.msg print e.msg
sys.exit(2) sys.exit(2)
print debq.name(), debq.version(), debq.release(), debq.arch() print debq.name(), debq.version(), debq.release(), debq.arch()

View File

@@ -114,7 +114,7 @@ if __name__ == '__main__':
import sys import sys
try: try:
pkgq = PackageQuery.query(sys.argv[1]) pkgq = PackageQuery.query(sys.argv[1])
except PackageError, e: except PackageError as e:
print e.msg print e.msg
sys.exit(2) sys.exit(2)
print pkgq.name() print pkgq.name()

View File

@@ -312,7 +312,7 @@ if __name__ == '__main__':
import sys import sys
try: try:
rpmq = RpmQuery.query(sys.argv[1]) rpmq = RpmQuery.query(sys.argv[1])
except RpmError, e: except RpmError as e:
print e.msg print e.msg
sys.exit(2) sys.exit(2)
print rpmq.name(), rpmq.version(), rpmq.release(), rpmq.arch(), rpmq.url() print rpmq.name(), rpmq.version(), rpmq.release(), rpmq.arch(), rpmq.url()

View File

@@ -19,7 +19,7 @@ class SafeWriter:
def write(self, s): def write(self, s):
try: try:
self.__get_writer().write(s) self.__get_writer().write(s)
except UnicodeEncodeError, e: except UnicodeEncodeError as e:
self.__get_writer().write(s.encode(self.__get_encoding())) self.__get_writer().write(s.encode(self.__get_encoding()))
def __getattr__(self, name): def __getattr__(self, name):