From e6e51498dd9bff8332012ec2ad86c3fb5617bfa8 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Fri, 3 Jan 2020 18:36:53 -0700 Subject: [PATCH] Clear ddrescue pane every minute --- scripts/wk/hw/ddrescue.py | 16 ++++++++-------- scripts/wk/hw/obj.py | 1 - scripts/wk/tmux.py | 10 ++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/scripts/wk/hw/ddrescue.py b/scripts/wk/hw/ddrescue.py index 5e7e858e..d61b9763 100644 --- a/scripts/wk/hw/ddrescue.py +++ b/scripts/wk/hw/ddrescue.py @@ -1673,10 +1673,8 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True): std.clear_screen() warning_message = '' - def _update_smart_pane(iteration): + def _update_smart_pane(): """Update SMART pane every 30 seconds.""" - if iteration % 30 != 0: - return state.source.update_smart_details() now = datetime.datetime.now(tz=TIMEZONE).strftime('%Y-%m-%d %H:%M %Z') with open(f'{state.log_dir}/smart.out', 'w') as _f: @@ -1691,10 +1689,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True): # Dry run if dry_run: - std.print_info('ddrescue cmd:') - for _c in cmd: - std.print_standard(f' {_c}') - std.pause() + LOG.info('ddrescue cmd: %s', cmd) return # Start ddrescue @@ -1703,7 +1698,12 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True): # ddrescue loop _i = 0 while True: - _update_smart_pane(_i) + if _i % 30 == 0: + # Update SMART pane + _update_smart_pane() + if _i % 60 == 0: + # Clear ddrescue pane + tmux.clear_pane() _i += 1 # Update progress diff --git a/scripts/wk/hw/obj.py b/scripts/wk/hw/obj.py index 1a7421b6..205d857a 100644 --- a/scripts/wk/hw/obj.py +++ b/scripts/wk/hw/obj.py @@ -1,6 +1,5 @@ """WizardKit: Hardware objects (mostly)""" # vim: sts=2 sw=2 ts=2 -# TODO: Get log-sec data under Linux and macOS import logging import pathlib diff --git a/scripts/wk/tmux.py b/scripts/wk/tmux.py index 2f5b32e7..b6d32848 100644 --- a/scripts/wk/tmux.py +++ b/scripts/wk/tmux.py @@ -24,6 +24,16 @@ def capture_pane(pane_id=None): return proc.stdout.strip() +def clear_pane(pane_id=None): + """Clear pane buffer for current or target pane.""" + cmd = ['tmux', 'send-keys', '-R'] + if pane_id: + cmd.extend(['-t', pane_id]) + + # Clear pane + run_program(cmd, check=False) + + def fix_layout(panes, layout, forced=False): """Fix pane sizes based on layout.""" if not (forced or layout_needs_fixed(panes, layout)):