Whamcloud - gitweb
LU-15515 contrib: Some style fixes for epython scripts 07/50607/4
authorOleg Drokin <green@whamcloud.com>
Tue, 11 Apr 2023 21:10:24 +0000 (17:10 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Apr 2023 06:28:39 +0000 (06:28 +0000)
tighten formatting, remove spurious if() constructs,
add int conversion for shifts

Test-Parameters: trivial
Change-Id: Id89bc8ca898d0d5870ca6955b185571060eafd58
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50607
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Feng Lei <flei@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
contrib/debug_tools/epython_scripts/crashlib/addrlib.py
contrib/debug_tools/epython_scripts/ldlm_dumplocks.py
contrib/debug_tools/epython_scripts/obd_devs.py

index 0724ddd..5387f04 100644 (file)
@@ -15,7 +15,7 @@ def ptov(physaddr):
 
 def phys2pfn(physaddr):
     """Convert a physical address to a page offset."""
-    return physaddr >> crashlib.cid.mdtbl.pageshift
+    return physaddr >> int(crashlib.cid.mdtbl.pageshift)
 
 def pfn2phys(pfn):
     """Convert a page offset into a physical address."""
index 5df8866..e8da915 100644 (file)
@@ -39,7 +39,7 @@ def lockmode2str(mode):
 def ldlm_dump_lock(lock, pos, lstname):
     obd = None
     imp = None
-    if(lock == None):
+    if lock == None:
         print("   NULL LDLM lock")
         return
     try:
@@ -51,13 +51,13 @@ def ldlm_dump_lock(lock, pos, lstname):
         print("   -- Lock: (ldlm_lock) %#x/%#x (rc: %d) (pos: %d/%s) (pid: %d)" % \
               (Addr(lock), lock.l_handle.h_cookie, refcounter,
               pos, lstname, lock.l_pid))
-        if(lock.l_conn_export):
+        if lock.l_conn_export:
             obd = lock.l_conn_export.exp_obd
-        if(lock.l_export and lock.l_export.exp_connection):
+        if lock.l_export and lock.l_export.exp_connection:
             print("       Node: NID %s (remote: %#x) export" % \
                   (ll.nid2str(lock.l_export.exp_connection.c_peer.nid),
                   lock.l_remote_handle.cookie))
-        elif(obd == None):
+        elif obd == None:
             print("       Node: local")
         else:
             imp = obd.u.cli.cl_import
@@ -80,17 +80,17 @@ def ldlm_dump_lock(lock, pos, lstname):
               lock.l_flags))
 
         lr_type = lock.l_resource.lr_type
-        if(lr_type == enum_LDLM_EXTENT):
+        if lr_type == enum_LDLM_EXTENT:
             print("       Extent: %d -> %d (req %d-%d)" % \
                   (lock.l_policy_data.l_extent.start,
                   lock.l_policy_data.l_extent.end,
                   lock.l_req_extent.start, lock.l_req_extent.end))
-        elif(lr_type == enum_LDLM_FLOCK):
+        elif lr_type == enum_LDLM_FLOCK:
             print("       Pid: %d Flock: 0x%x -> 0x%x" % \
                   (lock.l_policy_data.l_flock.pid,
                   lock.l_policy_data.l_flock.start,
                   lock.l_policy_data.l_flock.end))
-        elif(lr_type == enum_LDLM_IBITS):
+        elif lr_type == enum_LDLM_IBITS:
             print("       Bits: %#x" % \
                   (lock.l_policy_data.l_inodebits.bits))
     except (crash.error, IndexError):
index a6610df..20aab0d 100644 (file)
@@ -65,12 +65,12 @@ def print_one_device(obd, stats_flag):
     connect_cnt = 0
     inflight=0
     if obd.u.cli.cl_import:
-          impstate=IMP_STATE.get(obd.u.cli.cl_import.imp_state)
-          index=obd.u.cli.cl_import.imp_state_hist_idx - 1
-          if index > 0 and index < 16:
-            ish_time=obd.u.cli.cl_import.imp_state_hist[index].ish_time
-          inflight=obd.u.cli.cl_import.imp_inflight.counter
-          connect_cnt = obd.u.cli.cl_import.imp_conn_cnt
+        impstate = IMP_STATE.get(obd.u.cli.cl_import.imp_state)
+        index = obd.u.cli.cl_import.imp_state_hist_idx - 1
+        if index > 0 and index < 16:
+            ish_time = obd.u.cli.cl_import.imp_state_hist[index].ish_time
+        inflight = obd.u.cli.cl_import.imp_inflight.counter
+        connect_cnt = obd.u.cli.cl_import.imp_conn_cnt
 
     print("0x%-17x %-22s\t%-22s\t 0x%-17x 0x%-17x %-10s %-10d %5d %5d" % \
           (Addr(obd),
@@ -106,8 +106,8 @@ if __name__ == "__main__":
     description = "Displays the contents of global 'obd_devs'"
     parser = argparse.ArgumentParser(description=description)
     parser.add_argument("obd_device", nargs="?", default = [], type=toint,
-        help="print obd_device at argument address")
+        help = "print obd_device at argument address")
     parser.add_argument("-r", dest="stats_flag", action="count",
-        help="print the rpc_stats sequence for each client_obd")
+        help = "print the rpc_stats sequence for each client_obd")
     args = parser.parse_args()
     obd_devs(args)