]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
pwclient: Resolve pycode warnings
authorStephen Finucane <stephen@that.guru>
Wed, 10 Jan 2018 09:42:51 +0000 (09:42 +0000)
committerStephen Finucane <stephen@that.guru>
Thu, 17 May 2018 09:14:38 +0000 (10:14 +0100)
Either catch the specific exceptions or, in two cases, remove
unnecessary error-handling code.

Modified to include fix from commit aa304247.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
(cherry picked from commit 58160097f9571b808302226f02932c1bb0b68c57)

patchwork/bin/pwclient

index ceccbf3f2d3ea522d43e48d5b53e76a28a02025b..29cad89691657b7c96eebfcae192b1f02e1c1455 100755 (executable)
@@ -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,7 +709,7 @@ installed locales.
 
     try:
         rpc = xmlrpclib.Server(url, transport=transport)
-    except:
+    except (IOError, OSError):
         sys.stderr.write("Unable to connect to %s\n" % url)
         sys.exit(1)