Simplify _poweroff_source_drive()
This commit is contained in:
parent
4a34f5477d
commit
df1d2b713f
1 changed files with 4 additions and 8 deletions
|
|
@ -1907,19 +1907,15 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Sleep
|
# Sleep
|
||||||
i = 0
|
for i in range(1, idle_minutes*60, 1):
|
||||||
while i < idle_minutes*60:
|
|
||||||
if not poweroff_source_after_idle:
|
if not poweroff_source_after_idle:
|
||||||
# Countdown canceled, exit without powering-down drives
|
# Countdown canceled, exit without powering-down drives
|
||||||
return
|
return
|
||||||
if i % 600 == 0 and i > 0:
|
if i % 60 == 0:
|
||||||
if i == 600:
|
|
||||||
cli.print_standard(' ', flush=True)
|
|
||||||
cli.print_warning(
|
cli.print_warning(
|
||||||
f'Powering off source in {int((idle_minutes*60-i)/60)} minutes...',
|
f'Powering off source in {int((idle_minutes*60-i)/60)} minutes...',
|
||||||
)
|
)
|
||||||
std.sleep(5)
|
std.sleep(1)
|
||||||
i += 5
|
|
||||||
|
|
||||||
# Power off drive
|
# Power off drive
|
||||||
cmd = ['sudo', 'hdparm', '-Y', source_dev]
|
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
|
# Stop source poweroff countdown
|
||||||
cli.print_standard('Stopping device poweroff countdown...', flush=True)
|
cli.print_standard('Stopping device poweroff countdown...', flush=True)
|
||||||
poweroff_source_after_idle = False
|
poweroff_source_after_idle = False
|
||||||
poweroff_thread.join()
|
poweroff_thread.join() # type: ignore[reportUnboundVariable]
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
raise std.GenericAbort()
|
raise std.GenericAbort()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue