diff options
author | Stephen Finucane <stephen@that.guru> | 2018-01-10 09:42:51 +0000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2018-01-11 10:37:11 +0000 |
commit | 58160097f9571b808302226f02932c1bb0b68c57 (patch) | |
tree | aee63aaac6ce8fefb512eaad4ef3ea1651b717ac | |
parent | 572e15e2382c51137529c7c12080b976211f67ef (diff) | |
download | patchwork-58160097f9571b808302226f02932c1bb0b68c57.tar patchwork-58160097f9571b808302226f02932c1bb0b68c57.tar.gz |
pwclient: Resolve pycode warnings
Either catch the specific exceptions or, in two cases, remove
unnecessary error-handling code.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
-rwxr-xr-x | patchwork/bin/pwclient | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient index ceccbf3..857c8e9 100755 --- a/patchwork/bin/pwclient +++ b/patchwork/bin/pwclient @@ -388,7 +388,7 @@ def patch_id_from_hash(rpc, project, hash): # be super paranoid try: patch_id = int(patch_id) - except: + except ValueError: sys.stderr.write("Invalid patch ID obtained from server\n") sys.exit(1) return patch_id @@ -434,13 +434,11 @@ def main(): help='''Filter by delegate (name, e-mail substring search)''' ) filter_parser.add_argument( - '-n', metavar='MAX#', - type=int, + '-n', metavar='MAX#', type=int, help='''Return first n results''' ) filter_parser.add_argument( - '-N', metavar='MAX#', - type=int, + '-N', metavar='MAX#', type=int, help='''Return last N results''' ) filter_parser.add_argument( @@ -613,16 +611,10 @@ installed locales. 'Must specify one or more update options (-a or -s)') if args.get('n') is not None: - try: - filt.add("max_count", args.get('n')) - except: - action_parser.error("Invalid maximum count '%s'" % args.get('n')) + filt.add("max_count", args.get('n')) if args.get('N') is not None: - try: - filt.add("max_count", 0 - args.get('N')) - except: - action_parser.error("Invalid maximum count '%s'" % args.get('N')) + filt.add("max_count", 0 - args.get('N')) do_signoff = args.get('signoff') do_three_way = args.get('3way') @@ -668,7 +660,7 @@ installed locales. if not project_str: try: project_str = config.get('options', 'default') - except: + except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): action_parser.error( "No default project configured in %s\n" % CONFIG_FILE) @@ -717,8 +709,8 @@ installed locales. try: rpc = xmlrpclib.Server(url, transport=transport) - except: - sys.stderr.write("Unable to connect to %s\n" % url) + except (IOError, OSError): + sy.stderr.write("Unable to connect to %s\n" % url) sys.exit(1) # It should be safe to assume hash_str is not zero, but who knows.. |