Only show destination SMART data if present.

Also avoids crash when imaging
This commit is contained in:
2Shirt 2023-07-08 18:58:05 -07:00
parent df1d2b713f
commit a20fdf7bd3
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -1933,6 +1933,12 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
now = datetime.datetime.now(tz=TIMEZONE).strftime('%Y-%m-%d %H:%M %Z')
for dev_str in ('source', 'destination'):
dev = getattr(state, dev_str)
# Safety check
if not hasattr(dev, 'attributes'):
continue
# Update SMART data
out_path = f'{state.log_dir}/smart_{dev_str}.out'
update_smart_details(dev)
with open(out_path, 'w', encoding='utf-8') as _f:
@ -2065,11 +2071,12 @@ def run_recovery(state: State, main_menu, settings_menu, dry_run=True) -> None:
update_layout=False,
watch_file=f'{state.log_dir}/smart_source.out',
)
state.ui.add_info_pane(
percent=50,
update_layout=False,
watch_file=f'{state.log_dir}/smart_destination.out',
)
if hasattr(state.destination, 'attributes'):
state.ui.add_info_pane(
percent=50,
update_layout=False,
watch_file=f'{state.log_dir}/smart_destination.out',
)
if PLATFORM == 'Linux':
state.ui.add_worker_pane(lines=4, cmd='journal-datarec-monitor')
state.ui.set_current_pane_height(DDRESCUE_OUTPUT_HEIGHT)