statblk 1.22__tar.gz → 1.24__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: statblk
3
- Version: 1.22
3
+ Version: 1.24
4
4
  Summary: Gather essential disk and partition info for block devices and print it in a nice table
5
5
  Home-page: https://github.com/yufei-pan/statblk
6
6
  Author: Yufei Pan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: statblk
3
- Version: 1.22
3
+ Version: 1.24
4
4
  Summary: Gather essential disk and partition info for block devices and print it in a nice table
5
5
  Home-page: https://github.com/yufei-pan/statblk
6
6
  Author: Yufei Pan
@@ -276,7 +276,7 @@ except :
276
276
  def cache_decorator(func):
277
277
  return func
278
278
 
279
- version = '1.22'
279
+ version = '1.24'
280
280
  VERSION = version
281
281
  __version__ = version
282
282
  COMMIT_DATE = '2025-09-10'
@@ -501,7 +501,9 @@ def get_read_write_rate_throughput_iter(sysfs_block_path):
501
501
 
502
502
  # DRIVE_INFO = namedtuple("DRIVE_INFO",
503
503
  # ["NAME", "FSTYPE", "SIZE", "FSUSEPCT", "MOUNTPOINT", "SMART","RTPT",'WTPT', "LABEL", "UUID", "MODEL", "SERIAL", "DISCARD"])
504
- def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, best_only=False, formated_only=False, show_zero_size_devices=False,pseudo=False,tptDict = {},full=False):
504
+ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, best_only=False,
505
+ formated_only=False, show_zero_size_devices=False,pseudo=False,tptDict = {},
506
+ full=False,active_only=False):
505
507
  lsblk_result = multiCMD.run_command(f'lsblk -brnp -o NAME,SIZE,FSTYPE,UUID,LABEL',timeout=2,quiet=True,wait_for_return=False,return_object=True)
506
508
  block_devices = get_blocks()
507
509
  smart_infos = {}
@@ -526,6 +528,8 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
526
528
  if lsblk_result.returncode == 0:
527
529
  for line in lsblk_result.stdout:
528
530
  lsblk_name, lsblk_size, lsblk_fstype, lsblk_uuid, lsblk_label = line.split(' ', 4)
531
+ if lsblk_name.startswith(os.path.sep):
532
+ lsblk_name = os.path.realpath(lsblk_name)
529
533
  # the label can be \x escaped, we need to decode it
530
534
  lsblk_uuid = bytes(lsblk_uuid, "utf-8").decode("unicode_escape")
531
535
  lsblk_fstype = bytes(lsblk_fstype, "utf-8").decode("unicode_escape")
@@ -540,10 +544,12 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
540
544
  size_dict[lsblk_name] = int(lsblk_size)
541
545
  except Exception:
542
546
  pass
543
- output = [["NAME", "FSTYPE", "SIZE", "FSUSE%", "MOUNTPOINT", "SMART", "LABEL", "UUID", "MODEL", "SERIAL", "DISCARD","RTPT",'WTPT']]
547
+ output = [["NAME", "FSTYPE", "SIZE", "FSUSE%", "MOUNTPOINT", "SMART", "LABEL", "UUID", "MODEL", "SERIAL", "DISCARD","READ",'WRITE']]
544
548
  for device_name in target_devices:
545
549
  if mounted_only and device_name not in mount_table:
546
550
  continue
551
+ if active_only and device_name not in tptDict:
552
+ continue
547
553
  fstype = ''
548
554
  size = ''
549
555
  fsusepct = ''
@@ -580,6 +586,8 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
580
586
  if device_name in tptDict:
581
587
  try:
582
588
  rtpt, wtpt = next(tptDict[device_name])
589
+ if active_only and rtpt == 0 and wtpt == 0:
590
+ continue
583
591
  if print_bytes:
584
592
  rtpt = str(rtpt)
585
593
  wtpt = str(wtpt)
@@ -640,7 +648,8 @@ def main():
640
648
  parser.add_argument('-F','-fo','--formated_only', help="Show only formated filesystems", action="store_true")
641
649
  parser.add_argument('-M','-mo','--mounted_only', help="Show only mounted filesystems", action="store_true")
642
650
  parser.add_argument('-B','-bo','--best_only', help="Show only shortest mount point for each device", action="store_true")
643
- parser.add_argument('-a','--full', help="Show full device information, do not collapse drive info when length > console length", action="store_true")
651
+ parser.add_argument('-A','-ao','--active_only', help="Show only active devices (positive read/write activity)", action="store_true")
652
+ parser.add_argument('-R','--full', help="Show full device information, do not collapse drive info when length > console length", action="store_true")
644
653
  parser.add_argument('-P','--pseudo', help="Include pseudo file systems as well (tmpfs / nfs / cifs etc.)", action="store_true")
645
654
  parser.add_argument('--show_zero_size_devices', help="Show devices with zero size", action="store_true")
646
655
  parser.add_argument('print_period', nargs='?', default=0, type=int, help="If specified as a number, repeat the output every N seconds")
@@ -652,7 +661,7 @@ def main():
652
661
  results = get_drives_info(print_bytes = args.bytes, use_1024 = not args.si,
653
662
  mounted_only=args.mounted_only, best_only=args.best_only,
654
663
  formated_only=args.formated_only, show_zero_size_devices=args.show_zero_size_devices,
655
- pseudo=args.pseudo,tptDict=tptDict,full=args.full)
664
+ pseudo=args.pseudo,tptDict=tptDict,full=args.full,active_only=args.active_only)
656
665
  if args.json:
657
666
  import json
658
667
  print(json.dumps(results, indent=1))
File without changes
File without changes
File without changes