Add more pylint cleanup fixes
This commit is contained in:
parent
2761018a37
commit
812fd15011
5 changed files with 16 additions and 14 deletions
|
|
@ -165,7 +165,7 @@ class State():
|
||||||
disable_tests = False
|
disable_tests = False
|
||||||
|
|
||||||
# Skip already disabled devices
|
# Skip already disabled devices
|
||||||
if all([test.disabled for test in disk.tests.values()]):
|
if all(test.disabled for test in disk.tests.values()):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -176,7 +176,7 @@ class State():
|
||||||
if 'Disk Attributes' in disk.tests:
|
if 'Disk Attributes' in disk.tests:
|
||||||
disk.tests['Disk Attributes'].failed = True
|
disk.tests['Disk Attributes'].failed = True
|
||||||
disk.tests['Disk Attributes'].set_status('Failed')
|
disk.tests['Disk Attributes'].set_status('Failed')
|
||||||
except hw_obj.SMARTSelfTestInProgressError:
|
except hw_obj.SMARTSelfTestInProgressError as err:
|
||||||
if prep:
|
if prep:
|
||||||
std.print_warning(f'SMART self-test(s) in progress for {disk.path}')
|
std.print_warning(f'SMART self-test(s) in progress for {disk.path}')
|
||||||
if std.ask('Continue with all tests disabled for this device?'):
|
if std.ask('Continue with all tests disabled for this device?'):
|
||||||
|
|
@ -185,7 +185,7 @@ class State():
|
||||||
std.print_standard('Diagnostics aborted.')
|
std.print_standard('Diagnostics aborted.')
|
||||||
std.print_standard(' ')
|
std.print_standard(' ')
|
||||||
std.pause('Press Enter to exit...')
|
std.pause('Press Enter to exit...')
|
||||||
raise SystemExit(1)
|
raise SystemExit(1) from err
|
||||||
elif wait_for_self_tests:
|
elif wait_for_self_tests:
|
||||||
self_tests_in_progress = True
|
self_tests_in_progress = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -843,10 +843,10 @@ def disk_io_benchmark(state, test_objects, skip_usb=True):
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
)
|
)
|
||||||
except PermissionError:
|
except PermissionError as err:
|
||||||
# Since we're using sudo we can't kill dd
|
# Since we're using sudo we can't kill dd
|
||||||
# Assuming this happened during a CTRL+c
|
# Assuming this happened during a CTRL+c
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt from err
|
||||||
match = IO_RATE_REGEX.search(proc.stdout)
|
match = IO_RATE_REGEX.search(proc.stdout)
|
||||||
if match:
|
if match:
|
||||||
read_rates.append(
|
read_rates.append(
|
||||||
|
|
@ -982,7 +982,7 @@ def disk_self_test(state, test_objects):
|
||||||
state.update_progress_pane()
|
state.update_progress_pane()
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
if any([t.is_alive() for t in threads]):
|
if any(t.is_alive() for t in threads):
|
||||||
std.sleep(1)
|
std.sleep(1)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
@ -1061,7 +1061,7 @@ def disk_surface_scan(state, test_objects):
|
||||||
continue
|
continue
|
||||||
match = BADBLOCKS_REGEX.search(line)
|
match = BADBLOCKS_REGEX.search(line)
|
||||||
if match:
|
if match:
|
||||||
if all([s == '0' for s in match.groups()]):
|
if all(s == '0' for s in match.groups()):
|
||||||
test_obj.passed = True
|
test_obj.passed = True
|
||||||
test_obj.report.append(f' {line}')
|
test_obj.report.append(f' {line}')
|
||||||
test_obj.set_status('Passed')
|
test_obj.set_status('Passed')
|
||||||
|
|
@ -1104,7 +1104,7 @@ def disk_surface_scan(state, test_objects):
|
||||||
# Wait for all tests to complete
|
# Wait for all tests to complete
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
if any([t.is_alive() for t in threads]):
|
if any(t.is_alive() for t in threads):
|
||||||
state.update_progress_pane()
|
state.update_progress_pane()
|
||||||
std.sleep(5)
|
std.sleep(5)
|
||||||
else:
|
else:
|
||||||
|
|
@ -1275,7 +1275,7 @@ def run_diags(state, menu, quick_mode=False):
|
||||||
state.init_diags(menu)
|
state.init_diags(menu)
|
||||||
|
|
||||||
# Just return if no tests were selected
|
# Just return if no tests were selected
|
||||||
if not any([details['Enabled'] for details in state.tests.values()]):
|
if not any(details['Enabled'] for details in state.tests.values()):
|
||||||
std.print_warning('No tests selected?')
|
std.print_warning('No tests selected?')
|
||||||
std.pause()
|
std.pause()
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,11 @@ class BaseObj():
|
||||||
|
|
||||||
def all_tests_passed(self):
|
def all_tests_passed(self):
|
||||||
"""Check if all tests passed, returns bool."""
|
"""Check if all tests passed, returns bool."""
|
||||||
return all([results.passed for results in self.tests.values()])
|
return all(results.passed for results in self.tests.values())
|
||||||
|
|
||||||
def any_test_failed(self):
|
def any_test_failed(self):
|
||||||
"""Check if any test failed, returns bool."""
|
"""Check if any test failed, returns bool."""
|
||||||
return any([results.failed for results in self.tests.values()])
|
return any(results.failed for results in self.tests.values())
|
||||||
|
|
||||||
|
|
||||||
class CpuRam(BaseObj):
|
class CpuRam(BaseObj):
|
||||||
|
|
@ -707,7 +707,7 @@ def get_disks(skip_kits=False):
|
||||||
disks = [
|
disks = [
|
||||||
disk_obj for disk_obj in disks
|
disk_obj for disk_obj in disks
|
||||||
if not any(
|
if not any(
|
||||||
[WK_LABEL_REGEX.search(label) for label in disk_obj.get_labels()]
|
WK_LABEL_REGEX.search(label) for label in disk_obj.get_labels()
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ def case_insensitive_path(path):
|
||||||
for part in parts:
|
for part in parts:
|
||||||
try:
|
try:
|
||||||
real_path = case_insensitive_search(real_path, part)
|
real_path = case_insensitive_search(real_path, part)
|
||||||
except NotADirectoryError:
|
except NotADirectoryError as err:
|
||||||
# Reclassify error
|
# Reclassify error
|
||||||
raise FileNotFoundError(given_path)
|
raise FileNotFoundError(given_path) from err
|
||||||
real_path = pathlib.Path(real_path)
|
real_path = pathlib.Path(real_path)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ def mount(source, mount_point=None, read_write=False):
|
||||||
|
|
||||||
|
|
||||||
def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
|
def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
"""Mount all detected volumes, returns list.
|
"""Mount all detected volumes, returns list.
|
||||||
|
|
||||||
NOTE: If device_path is specified then only volumes
|
NOTE: If device_path is specified then only volumes
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,7 @@ def run_sfc_scan():
|
||||||
|
|
||||||
# Registry Functions
|
# Registry Functions
|
||||||
def reg_delete_key(hive, key, recurse=False):
|
def reg_delete_key(hive, key, recurse=False):
|
||||||
|
# pylint: disable=raise-missing-from
|
||||||
"""Delete a key from the registry.
|
"""Delete a key from the registry.
|
||||||
|
|
||||||
NOTE: If recurse is False then it will only work on empty keys.
|
NOTE: If recurse is False then it will only work on empty keys.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue