Move detect drives logic to its own function

This commit is contained in:
2Shirt 2022-02-19 18:42:41 -07:00
parent 4550b13565
commit b3f4a31ed2
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -1532,6 +1532,18 @@ def clean_working_dir(working_dir):
shutil.move(entry.path, new_path) shutil.move(entry.path, new_path)
def detect_drives(state):
"""Detect connected drives and check source/dest selections."""
std.clear_screen()
std.print_warning(DETECT_DRIVES_NOTICE)
if std.ask('Are you sure you proceed?'):
std.print_standard('Forcing controllers to rescan for devices...')
cmd = 'echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan'
exe.run_program(cmd, check=False, shell=True)
if source_or_destination_changed(state):
std.abort()
def format_status_string(status, width): def format_status_string(status, width):
"""Format colored status string, returns str.""" """Format colored status string, returns str."""
color = None color = None
@ -1895,14 +1907,7 @@ def main():
# Detect drives # Detect drives
if 'Detect drives' in selection[0]: if 'Detect drives' in selection[0]:
std.clear_screen() detect_drives(state)
std.print_warning(DETECT_DRIVES_NOTICE)
if std.ask('Are you sure you proceed?'):
std.print_standard('Forcing controllers to rescan for devices...')
cmd = 'echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan'
exe.run_program(cmd, check=False, shell=True)
if source_or_destination_changed(state):
std.abort()
# Start recovery # Start recovery
if 'Start' in selection: if 'Start' in selection: