Add DRIVE_POWEROFF_TIMEOUT to wk.cfg.ddrescue

This replaces a magic number
This commit is contained in:
2Shirt 2021-04-08 23:40:00 -06:00
parent 830e088ccf
commit 9d3508909a
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 6 additions and 2 deletions

View file

@ -49,6 +49,7 @@ DDRESCUE_SETTINGS = {
'--timeout': {'Selected': False, 'Value': '30m', },
},
}
DRIVE_POWEROFF_TIMEOUT = 90
PARTITION_TYPES = {
'GPT': {
'NTFS': 'EBD0A0A2-B9E5-4433-87C0-68B6B72699C7', # Basic Data Partition

View file

@ -1918,7 +1918,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True):
std.clear_screen()
warning_message = ''
def _poweroff_source_drive(idle_minutes=120):
def _poweroff_source_drive(idle_minutes):
"""Power off source drive after a while."""
source_dev = state.source.path.name
@ -2022,7 +2022,10 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True):
# Check result
if proc.poll():
# True if return code is non-zero (poll() returns None if still running)
poweroff_thread = exe.start_thread(_poweroff_source_drive)
poweroff_thread = exe.start_thread(
_poweroff_source_drive,
cfg.ddrescue.DRIVE_POWEROFF_TIMEOUT,
)
warning_message = 'Error(s) encountered, see message above'
state.update_top_panes()
if warning_message: