From df1d2b713f153081ec99131a4ff9d787e2d68ced Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 8 Jul 2023 18:37:42 -0700 Subject: [PATCH] Simplify _poweroff_source_drive() --- scripts/wk/clone/ddrescue.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/wk/clone/ddrescue.py b/scripts/wk/clone/ddrescue.py index abfd0d6b..aa71b6d5 100644 --- a/scripts/wk/clone/ddrescue.py +++ b/scripts/wk/clone/ddrescue.py @@ -1907,19 +1907,15 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None: return # Sleep - i = 0 - while i < idle_minutes*60: + for i in range(1, idle_minutes*60, 1): if not poweroff_source_after_idle: # Countdown canceled, exit without powering-down drives return - if i % 600 == 0 and i > 0: - if i == 600: - cli.print_standard(' ', flush=True) + if i % 60 == 0: cli.print_warning( f'Powering off source in {int((idle_minutes*60-i)/60)} minutes...', ) - std.sleep(5) - i += 5 + std.sleep(1) # Power off drive cmd = ['sudo', 'hdparm', '-Y', source_dev] @@ -2034,7 +2030,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None: # Stop source poweroff countdown cli.print_standard('Stopping device poweroff countdown...', flush=True) poweroff_source_after_idle = False - poweroff_thread.join() + poweroff_thread.join() # type: ignore[reportUnboundVariable] # Done raise std.GenericAbort()