Show SMART data for both devices in ddrescue-tui

This commit is contained in:
2Shirt 2023-07-05 15:00:01 -07:00
parent 7499639c5c
commit ebd1bbda18
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -87,11 +87,6 @@ REGEX_REMAINING_TIME = re.compile(
r'\s*(?P<na>n/a)?',
re.IGNORECASE
)
PANE_RATIOS = (
12, # SMART
22, # ddrescue progress
4, # Journal (kernel messages)
)
PLATFORM = std.PLATFORM
RECOMMENDED_FSTYPES = re.compile(r'^(ext[234]|ntfs|xfs)$')
if PLATFORM == 'Darwin':
@ -1937,19 +1932,22 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
'Press Enter to return to main menu...', end='', flush=True,
)
def _update_smart_pane() -> None:
"""Update SMART pane every 30 seconds."""
update_smart_details(state.source)
def _update_smart_panes() -> None:
"""Update SMART panes every 30 seconds."""
now = datetime.datetime.now(tz=TIMEZONE).strftime('%Y-%m-%d %H:%M %Z')
with open(f'{state.log_dir}/smart.out', 'w', encoding='utf-8') as _f:
_f.write(
ansi.color_string(
['SMART Attributes', f'Updated: {now}\n'],
['BLUE', 'YELLOW'],
sep='\t\t',
),
)
_f.write('\n'.join(state.source.generate_report(header=False)))
for dev_str in ('source', 'destination'):
dev = getattr(state, dev_str)
out_path = f'{state.log_dir}/smart_{dev_str}.out'
update_smart_details(dev)
with open(out_path, 'w', encoding='utf-8') as _f:
_f.write(
ansi.color_string(
['SMART Attributes', f'Updated: {now}\n'],
['BLUE', 'YELLOW'],
sep='\t\t',
),
)
_f.write('\n'.join(dev.generate_report(header=False)))
# Dry run
if dry_run:
@ -1972,7 +1970,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
while True:
if _i % 30 == 0:
# Update SMART pane
_update_smart_pane()
_update_smart_panes()
# Check destination
warning_message = check_destination_health(state.destination)
@ -2069,7 +2067,12 @@ def run_recovery(state: State, main_menu, settings_menu, dry_run=True) -> None:
state.ui.add_info_pane(
percent=50,
update_layout=False,
watch_file=f'{state.log_dir}/smart.out',
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 PLATFORM == 'Linux':
state.ui.add_worker_pane(lines=4, cmd='journal-datarec-monitor')