From bcd46d4017c3e3296edde8a66b83eae6a1b8c56d Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 30 Dec 2019 19:25:46 -0700 Subject: [PATCH] Added SMART/Journal panes --- scripts/wk/cfg/ddrescue.py | 2 -- scripts/wk/hw/ddrescue.py | 34 ++++++++++++++++++++++------------ scripts/wk/hw/obj.py | 10 ++++++---- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/scripts/wk/cfg/ddrescue.py b/scripts/wk/cfg/ddrescue.py index 4a9c8e02..e617bae5 100644 --- a/scripts/wk/cfg/ddrescue.py +++ b/scripts/wk/cfg/ddrescue.py @@ -2,8 +2,6 @@ # pylint: disable=bad-whitespace,line-too-long # vim: sts=2 sw=2 ts=2 -import re - from collections import OrderedDict diff --git a/scripts/wk/hw/ddrescue.py b/scripts/wk/hw/ddrescue.py index b7da2cfa..c85ad733 100644 --- a/scripts/wk/hw/ddrescue.py +++ b/scripts/wk/hw/ddrescue.py @@ -405,17 +405,19 @@ class State(): if forced or needs_fixed: self.update_top_panes() - # SMART/Journal + # Return if Progress pane not present if 'Progress' not in self.panes: - # Assumning we're still selecting source/dest return - height = tmux.get_pane_size(self.panes['Progress'])[1] - 2 - p_ratios = [int((x/sum(PANE_RATIOS)) * height) for x in PANE_RATIOS] - if 'SMART' in self.panes: - tmux.resize_pane(self.panes['SMART'], height=p_ratios[0]) - tmux.resize_pane(height=p_ratios[1]) - if 'Journal' in self.panes: - tmux.resize_pane(self.panes['Journal'], height=p_ratios[2]) + + # SMART/Journal + if forced or needs_fixed: + height = tmux.get_pane_size(self.panes['Progress'])[1] - 2 + p_ratios = [int((x/sum(PANE_RATIOS)) * height) for x in PANE_RATIOS] + if 'SMART' in self.panes: + tmux.resize_pane(self.panes['SMART'], height=p_ratios[0]) + tmux.resize_pane(height=p_ratios[1]) + if 'Journal' in self.panes: + tmux.resize_pane(self.panes['Journal'], height=p_ratios[2]) def fix_tmux_layout_loop(self): """Fix tmux layout on a loop. @@ -1349,16 +1351,24 @@ def mount_raw_image_macos(path): def run_recovery(state, main_menu, settings_menu): """Run recovery passes.""" atexit.register(state.save_debug_reports) - state.update_progress_pane('Active') # Start SMART/Journal - # TODO + state.panes['SMART'] = tmux.split_window( + behind=True, lines=12, vertical=True, + watch_file=f'{state.log_dir}/smart.out', + ) + state.panes['Journal'] = tmux.split_window( + lines=4, vertical=True, cmd='journalctl --dmesg --follow', + ) # TODO # Run ddrescue + state.update_progress_pane('Active') # Stop SMART/Journal - # TODO + for pane in ('SMART', 'Journal'): + if pane in state.panes: + tmux.kill_pane(state.panes.pop(pane)) # Done state.save_debug_reports() diff --git a/scripts/wk/hw/obj.py b/scripts/wk/hw/obj.py index f473afaf..490d96f7 100644 --- a/scripts/wk/hw/obj.py +++ b/scripts/wk/hw/obj.py @@ -275,15 +275,17 @@ class Disk(BaseObj): # Done return report - def generate_report(self): + def generate_report(self, header=True): """Generate Disk report, returns list.""" report = [] - report.append(color_string(f'Device ({self.path.name})', 'BLUE')) - report.append(f' {self.description}') + if header: + report.append(color_string(f'Device ({self.path.name})', 'BLUE')) + report.append(f' {self.description}') # Attributes if self.attributes: - report.append(color_string('Attributes', 'BLUE')) + if header: + report.append(color_string('Attributes', 'BLUE')) report.extend(self.generate_attribute_report()) # Notes