]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/ceph_argparse.py: drop unused variable
authorKefu Chai <kchai@redhat.com>
Sun, 20 Dec 2020 05:04:59 +0000 (13:04 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 20 Dec 2020 17:26:46 +0000 (01:26 +0800)
and other PEP8 compliance cleanups

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/ceph_argparse.py

index ac985e5113e11838e53d3e71b6dee94cb9a2d6fa..6e3a7b8e6dcdc3e2447e1e9498fc9e5f4f3ffb88 100644 (file)
@@ -564,11 +564,11 @@ class CephFragment(CephArgtype):
             raise ArgumentFormat("{0} not a hex integer".format(val))
         try:
             int(val)
-        except:
+        except ValueError:
             raise ArgumentFormat('can\'t convert {0} to integer'.format(val))
         try:
             int(bits)
-        except:
+        except ValueError:
             raise ArgumentFormat('can\'t convert {0} to integer'.format(bits))
         self.val = s
 
@@ -1077,15 +1077,12 @@ def validate(args, signature, flags=0, partial=False):
             # Have an arg; validate it
             try:
                 validate_one(myarg, desc)
-                valid = True
             except ArgumentError as e:
-                valid = False
-
                 # argument mismatch
                 if not desc.req:
                     # if not required, just push back; it might match
                     # the next arg
-                    save_exception = [ myarg, e ]
+                    save_exception = [myarg, e]
                     myargs.insert(0, myarg)
                     break
                 else:
@@ -1171,9 +1168,9 @@ def validate_command(sigdict, args, verbose=False):
     # (relies on a cmdsig being key,val where val is a list of len 1)
 
     def grade(cmd):
-      # prefer optional arguments over required ones
-      sigs = cmd['sig']
-      return sum(map(lambda sig: sig.req, sigs))
+        # prefer optional arguments over required ones
+        sigs = cmd['sig']
+        return sum(map(lambda sig: sig.req, sigs))
 
     bestcmds_sorted = sorted(bestcmds, key=grade)
     if verbose:
@@ -1227,7 +1224,6 @@ def validate_command(sigdict, args, verbose=False):
     return valid_dict
 
 
-
 def find_cmd_target(childargs):
     """
     Using a minimal validation, figure out whether the command
@@ -1312,7 +1308,6 @@ class RadosThread(threading.Thread):
 
 
 def run_in_thread(func, *args, **kwargs):
-    interrupt = False
     timeout = kwargs.pop('timeout', 0)
     if timeout == 0 or timeout == None:
         # python threading module will just get blocked if timeout is `None`,