From ebd1bbda18110c077fb2282a74efb4adc9fda9b4 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Wed, 5 Jul 2023 15:00:01 -0700 Subject: [PATCH] Show SMART data for both devices in ddrescue-tui --- scripts/wk/clone/ddrescue.py | 41 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/scripts/wk/clone/ddrescue.py b/scripts/wk/clone/ddrescue.py index 22596e5e..6e6f9568 100644 --- a/scripts/wk/clone/ddrescue.py +++ b/scripts/wk/clone/ddrescue.py @@ -87,11 +87,6 @@ REGEX_REMAINING_TIME = re.compile( r'\s*(?Pn/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')