statblk 1.21__tar.gz → 1.23__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.
- {statblk-1.21 → statblk-1.23}/PKG-INFO +1 -1
- {statblk-1.21 → statblk-1.23}/statblk.egg-info/PKG-INFO +1 -1
- {statblk-1.21 → statblk-1.23}/statblk.py +23 -11
- {statblk-1.21 → statblk-1.23}/README.txt +0 -0
- {statblk-1.21 → statblk-1.23}/setup.cfg +0 -0
- {statblk-1.21 → statblk-1.23}/setup.py +0 -0
- {statblk-1.21 → statblk-1.23}/statblk.egg-info/SOURCES.txt +0 -0
- {statblk-1.21 → statblk-1.23}/statblk.egg-info/dependency_links.txt +0 -0
- {statblk-1.21 → statblk-1.23}/statblk.egg-info/entry_points.txt +0 -0
- {statblk-1.21 → statblk-1.23}/statblk.egg-info/requires.txt +0 -0
- {statblk-1.21 → statblk-1.23}/statblk.egg-info/top_level.txt +0 -0
@@ -276,7 +276,7 @@ except :
|
|
276
276
|
def cache_decorator(func):
|
277
277
|
return func
|
278
278
|
|
279
|
-
version = '1.
|
279
|
+
version = '1.23'
|
280
280
|
VERSION = version
|
281
281
|
__version__ = version
|
282
282
|
COMMIT_DATE = '2025-09-10'
|
@@ -293,11 +293,11 @@ def read_text(path):
|
|
293
293
|
def read_int(path):
|
294
294
|
s = read_text(path)
|
295
295
|
if s is None:
|
296
|
-
return
|
296
|
+
return 0
|
297
297
|
try:
|
298
298
|
return int(s)
|
299
299
|
except Exception:
|
300
|
-
return
|
300
|
+
return 0
|
301
301
|
|
302
302
|
def build_symlink_dict(dir_path):
|
303
303
|
"""
|
@@ -337,7 +337,7 @@ def read_discard_support(sysfs_block_path):
|
|
337
337
|
return 'N/A'
|
338
338
|
dmbytes = read_int(os.path.join(sysfs_block_path, "queue", "discard_max_bytes"))
|
339
339
|
try:
|
340
|
-
if
|
340
|
+
if dmbytes > 0:
|
341
341
|
return 'Yes'
|
342
342
|
else:
|
343
343
|
return 'No'
|
@@ -345,7 +345,7 @@ def read_discard_support(sysfs_block_path):
|
|
345
345
|
return 'N/A'
|
346
346
|
|
347
347
|
@cache_decorator
|
348
|
-
def
|
348
|
+
def get_real_sysfs_device_path(sysfs_block_path):
|
349
349
|
"""
|
350
350
|
Return the sysfs 'device' directory for this block node (resolves partition
|
351
351
|
to its parent device as well).
|
@@ -360,7 +360,7 @@ def get_parent_device_sysfs(sysfs_block_path):
|
|
360
360
|
def read_model_and_serial(sysfs_block_path):
|
361
361
|
if not sysfs_block_path or not os.path.isdir(sysfs_block_path):
|
362
362
|
return '', ''
|
363
|
-
device_path =
|
363
|
+
device_path = get_real_sysfs_device_path(sysfs_block_path)
|
364
364
|
model = read_text(os.path.join(device_path, "model"))
|
365
365
|
serial = read_text(os.path.join(device_path, "serial"))
|
366
366
|
if serial is None:
|
@@ -375,12 +375,20 @@ def read_model_and_serial(sysfs_block_path):
|
|
375
375
|
serial = ''
|
376
376
|
return model, serial
|
377
377
|
|
378
|
+
def read_size(sysfs_block_path):# -> tuple[int | None, Any] | Literal['']:
|
379
|
+
if not sysfs_block_path or not os.path.isdir(sysfs_block_path):
|
380
|
+
return ''
|
381
|
+
size = read_int(os.path.join(sysfs_block_path, "size"))
|
382
|
+
return size
|
383
|
+
|
378
384
|
MountEntry = namedtuple("MountEntry", ["MOUNTPOINT", "FSTYPE", "OPTIONS"])
|
379
385
|
def parseMount():
|
380
386
|
rtn = multiCMD.run_command('mount',timeout=1,quiet=True)
|
381
387
|
mount_table = defaultdict(list)
|
382
388
|
for line in rtn:
|
383
389
|
device_name, _, line = line.partition(' on ')
|
390
|
+
if device_name.startswith(os.path.sep):
|
391
|
+
device_name = os.path.realpath(device_name)
|
384
392
|
mount_point, _, line = line.partition(' type ')
|
385
393
|
fstype, _ , options = line.partition(' (')
|
386
394
|
options = options.rstrip(')').split(',')
|
@@ -429,7 +437,7 @@ def get_sector_size(sysfs_block_path):
|
|
429
437
|
if get_partition_parent_name(sysfs_block_path):
|
430
438
|
sysfs_block_path = os.path.join('/sys/class/block', os.path.basename(get_partition_parent_name(sysfs_block_path)))
|
431
439
|
sector_size = read_int(os.path.join(sysfs_block_path, "queue", "hw_sector_size"))
|
432
|
-
if sector_size
|
440
|
+
if sector_size == 0:
|
433
441
|
sector_size = read_int(os.path.join(sysfs_block_path, "queue", "logical_block_size"))
|
434
442
|
return sector_size if sector_size else 512
|
435
443
|
|
@@ -503,7 +511,7 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
|
|
503
511
|
if parent_name not in smart_infos:
|
504
512
|
smart_infos[parent_name] = multiCMD.run_command(f'{SMARTCTL_PATH} -H {parent_name}',timeout=2,quiet=True,wait_for_return=False,return_object=True)
|
505
513
|
if block_device not in tptDict:
|
506
|
-
sysfs_block_path = os.path.
|
514
|
+
sysfs_block_path = os.path.join('/sys/class/block', os.path.basename(block_device))
|
507
515
|
tptDict[block_device] = get_read_write_rate_throughput_iter(sysfs_block_path)
|
508
516
|
mount_table = parseMount()
|
509
517
|
target_devices = set(block_devices)
|
@@ -518,6 +526,8 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
|
|
518
526
|
if lsblk_result.returncode == 0:
|
519
527
|
for line in lsblk_result.stdout:
|
520
528
|
lsblk_name, lsblk_size, lsblk_fstype, lsblk_uuid, lsblk_label = line.split(' ', 4)
|
529
|
+
if lsblk_name.startswith(os.path.sep):
|
530
|
+
lsblk_name = os.path.realpath(lsblk_name)
|
521
531
|
# the label can be \x escaped, we need to decode it
|
522
532
|
lsblk_uuid = bytes(lsblk_uuid, "utf-8").decode("unicode_escape")
|
523
533
|
lsblk_fstype = bytes(lsblk_fstype, "utf-8").decode("unicode_escape")
|
@@ -568,6 +578,7 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
|
|
568
578
|
elif "denied" in line:
|
569
579
|
smart = 'DENIED'
|
570
580
|
break
|
581
|
+
size_bytes = read_size(os.path.join('/sys/class/block', os.path.basename(device_name)))
|
571
582
|
if device_name in tptDict:
|
572
583
|
try:
|
573
584
|
rtpt, wtpt = next(tptDict[device_name])
|
@@ -603,13 +614,14 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
|
|
603
614
|
else:
|
604
615
|
size = multiCMD.format_bytes(size_bytes, use_1024_bytes=use_1024, to_str=True) + 'B'
|
605
616
|
if not full:
|
606
|
-
device_name = device_name.
|
617
|
+
device_name = device_name.replace('/dev/', '')
|
607
618
|
output.append([device_name, fstype, size, fsusepct, mountpoint, smart, label, uuid, model, serial, discard, rtpt, wtpt])
|
608
619
|
else:
|
609
620
|
if formated_only and device_name not in fstype_dict:
|
610
621
|
continue
|
611
622
|
fstype = fstype_dict.get(device_name, '')
|
612
|
-
|
623
|
+
if not size_bytes:
|
624
|
+
size_bytes = size_dict.get(device_name, 0)
|
613
625
|
if size_bytes == 0 and not show_zero_size_devices:
|
614
626
|
continue
|
615
627
|
if print_bytes:
|
@@ -617,7 +629,7 @@ def get_drives_info(print_bytes = False, use_1024 = False, mounted_only=False, b
|
|
617
629
|
else:
|
618
630
|
size = multiCMD.format_bytes(size_bytes, use_1024_bytes=use_1024, to_str=True) + 'B'
|
619
631
|
if not full:
|
620
|
-
device_name = device_name.
|
632
|
+
device_name = device_name.replace('/dev/', '')
|
621
633
|
output.append([device_name, fstype, size, fsusepct, mountpoint, smart, label, uuid, model, serial, discard, rtpt, wtpt])
|
622
634
|
return output
|
623
635
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|