Replace references to details with attributes
This commit is contained in:
parent
4647efb971
commit
5ffa6d8261
2 changed files with 11 additions and 14 deletions
|
|
@ -28,9 +28,6 @@ from wk.cfg.ddrescue import (
|
||||||
DDRESCUE_SPECIFIC_PASS_SETTINGS,
|
DDRESCUE_SPECIFIC_PASS_SETTINGS,
|
||||||
)
|
)
|
||||||
from wk.hw import disk as hw_disk
|
from wk.hw import disk as hw_disk
|
||||||
from wk.hw import sensors as hw_sensors
|
|
||||||
from wk.hw import system as hw_system
|
|
||||||
from wk.hw.test import Test
|
|
||||||
|
|
||||||
|
|
||||||
# STATIC VARIABLES
|
# STATIC VARIABLES
|
||||||
|
|
@ -276,7 +273,7 @@ class BlockPair():
|
||||||
dest_size = -1
|
dest_size = -1
|
||||||
if self.destination.exists():
|
if self.destination.exists():
|
||||||
dest_obj = hw_disk.Disk(self.destination)
|
dest_obj = hw_disk.Disk(self.destination)
|
||||||
dest_size = dest_obj.details['size']
|
dest_size = dest_obj.size
|
||||||
del dest_obj
|
del dest_obj
|
||||||
|
|
||||||
# Check destination size if cloning
|
# Check destination size if cloning
|
||||||
|
|
@ -1674,7 +1671,7 @@ def get_object(path):
|
||||||
obj = hw_disk.Disk(path)
|
obj = hw_disk.Disk(path)
|
||||||
|
|
||||||
# Child/Parent check
|
# Child/Parent check
|
||||||
parent = obj.details['parent']
|
parent = obj.raw_details['parent']
|
||||||
if parent:
|
if parent:
|
||||||
std.print_warning(f'"{obj.path}" is a child device')
|
std.print_warning(f'"{obj.path}" is a child device')
|
||||||
if std.ask(f'Use parent device "{parent}" instead?'):
|
if std.ask(f'Use parent device "{parent}" instead?'):
|
||||||
|
|
@ -1836,7 +1833,7 @@ def source_or_destination_changed(state):
|
||||||
elif isinstance(obj, hw_disk.Disk):
|
elif isinstance(obj, hw_disk.Disk):
|
||||||
compare_dev = hw_disk.Disk(obj.path)
|
compare_dev = hw_disk.Disk(obj.path)
|
||||||
for key in ('model', 'serial'):
|
for key in ('model', 'serial'):
|
||||||
changed = changed or obj.details[key] != compare_dev.details[key]
|
changed = changed or getattr(obj, key) != getattr(compare_dev, key)
|
||||||
|
|
||||||
# Update top panes
|
# Update top panes
|
||||||
state.update_top_panes()
|
state.update_top_panes()
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ class State():
|
||||||
elif 'Disk' in name:
|
elif 'Disk' in name:
|
||||||
for disk in self.disks:
|
for disk in self.disks:
|
||||||
test_obj = Test(dev=disk, label=disk.path.name, name=name)
|
test_obj = Test(dev=disk, label=disk.path.name, name=name)
|
||||||
disk.test.append(test_obj)
|
disk.tests.append(test_obj)
|
||||||
self.tests[name]['Objects'].append(test_obj)
|
self.tests[name]['Objects'].append(test_obj)
|
||||||
|
|
||||||
# Run safety checks
|
# Run safety checks
|
||||||
|
|
@ -592,7 +592,7 @@ def check_io_benchmark_results(test_obj, rate_list, graph_width):
|
||||||
avg_read = sum(rate_list) / len(rate_list)
|
avg_read = sum(rate_list) / len(rate_list)
|
||||||
min_read = min(rate_list)
|
min_read = min(rate_list)
|
||||||
max_read = max(rate_list)
|
max_read = max(rate_list)
|
||||||
if test_obj.dev.details['ssd']:
|
if test_obj.dev.ssd:
|
||||||
thresh_min = cfg.hw.THRESH_SSD_MIN
|
thresh_min = cfg.hw.THRESH_SSD_MIN
|
||||||
thresh_avg_high = cfg.hw.THRESH_SSD_AVG_HIGH
|
thresh_avg_high = cfg.hw.THRESH_SSD_AVG_HIGH
|
||||||
thresh_avg_low = cfg.hw.THRESH_SSD_AVG_LOW
|
thresh_avg_low = cfg.hw.THRESH_SSD_AVG_LOW
|
||||||
|
|
@ -878,7 +878,7 @@ def disk_io_benchmark(state, test_objects, skip_usb=True):
|
||||||
|
|
||||||
# Get dd values or bail
|
# Get dd values or bail
|
||||||
try:
|
try:
|
||||||
dd_values = calc_io_dd_values(test_obj.dev.details['size'])
|
dd_values = calc_io_dd_values(test_obj.dev.size)
|
||||||
except DeviceTooSmallError:
|
except DeviceTooSmallError:
|
||||||
test_obj.set_status('N/A')
|
test_obj.set_status('N/A')
|
||||||
test_obj.report.append(
|
test_obj.report.append(
|
||||||
|
|
@ -951,7 +951,7 @@ def disk_io_benchmark(state, test_objects, skip_usb=True):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip USB devices if requested
|
# Skip USB devices if requested
|
||||||
if skip_usb and test.dev.details['bus'] == 'USB':
|
if skip_usb and test.dev.bus == 'USB':
|
||||||
test.set_status('Skipped')
|
test.set_status('Skipped')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -1098,14 +1098,14 @@ def disk_surface_scan(state, test_objects):
|
||||||
test_obj.set_status('Working')
|
test_obj.set_status('Working')
|
||||||
|
|
||||||
# Increase block size if necessary
|
# Increase block size if necessary
|
||||||
if (dev.details['phy-sec'] == 4096
|
if (dev.phy_sec == 4096
|
||||||
or dev.details['size'] >= cfg.hw.BADBLOCKS_LARGE_DISK):
|
or dev.size >= cfg.hw.BADBLOCKS_LARGE_DISK):
|
||||||
block_size = '4096'
|
block_size = '4096'
|
||||||
|
|
||||||
# Start scan
|
# Start scan
|
||||||
cmd = ['sudo', 'badblocks', '-sv', '-b', block_size, '-e', '1', dev_path]
|
cmd = ['sudo', 'badblocks', '-sv', '-b', block_size, '-e', '1', dev_path]
|
||||||
with open(log_path, 'a', encoding='utf-8') as _f:
|
with open(log_path, 'a', encoding='utf-8') as _f:
|
||||||
size_str = std.bytes_to_string(dev.details["size"], use_binary=False)
|
size_str = std.bytes_to_string(dev.size, use_binary=False)
|
||||||
_f.write(
|
_f.write(
|
||||||
std.color_string(
|
std.color_string(
|
||||||
['[', dev.path.name, ' ', size_str, ']\n'],
|
['[', dev.path.name, ' ', size_str, ']\n'],
|
||||||
|
|
@ -1156,7 +1156,7 @@ def disk_surface_scan(state, test_objects):
|
||||||
line for line in disk.generate_attribute_report() if 'failed' in line
|
line for line in disk.generate_attribute_report() if 'failed' in line
|
||||||
]
|
]
|
||||||
if failed_attributes:
|
if failed_attributes:
|
||||||
size_str = std.bytes_to_string(disk.details["size"], use_binary=False)
|
size_str = std.bytes_to_string(disk.size, use_binary=False)
|
||||||
std.print_colored(
|
std.print_colored(
|
||||||
['[', disk.path.name, ' ', size_str, ']'],
|
['[', disk.path.name, ' ', size_str, ']'],
|
||||||
[None, 'BLUE', None, 'CYAN', None],
|
[None, 'BLUE', None, 'CYAN', None],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue