Clear ddrescue pane every minute

This commit is contained in:
2Shirt 2020-01-03 18:36:53 -07:00
parent 30a5df8a00
commit e6e51498dd
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 18 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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)):