From 1ed630997151d4e28a20a14f9e629029d663d73e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 22 Dec 2019 19:05:32 -0700 Subject: [PATCH] Include selected source parts in 1st confirmation --- scripts/wk/hw/ddrescue.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/wk/hw/ddrescue.py b/scripts/wk/hw/ddrescue.py index 21dd52bd..bb65feb6 100644 --- a/scripts/wk/hw/ddrescue.py +++ b/scripts/wk/hw/ddrescue.py @@ -183,7 +183,7 @@ class State(): bp_dest = pathlib.Path(f'{self.destination.path}/{part_TODO}.dd') # TODO: add bp(bp_source, bp_dest, map_dir=working_dir) - def confirm_selections(self, mode, prompt, map_dir=None): + def confirm_selections(self, mode, prompt, map_dir=None, source_parts=None): """Show selection details and prompt for confirmation.""" report = [] @@ -238,6 +238,20 @@ class State(): ) report.append(' ') + # Source part(s) selected + if source_parts: + report.append(std.color_string('Source Part(s) selected', 'GREEN')) + if self.source.path.samefile(source_parts[0].path): + report.append('Whole Disk') + else: + report.append(std.color_string(f'{"NAME":<9} SIZE', 'BLUE')) + for part in source_parts: + report.append( + f'{part.path.name:<9} ' + f'{std.bytes_to_string(part.details["size"], use_binary=False)}' + ) + report.append(' ') + # Prompt user std.clear_screen() std.print_report(report) @@ -245,7 +259,6 @@ class State(): raise std.GenericAbort() def fix_tmux_layout(self, forced=True): - # pylint: disable=unused-argument """Fix tmux layout based on cfg.ddrescue.TMUX_LAYOUT.""" needs_fixed = tmux.layout_needs_fixed(self.panes, self.layout) @@ -325,7 +338,11 @@ class State(): self.update_progress_pane() # Confirmation #1 - self.confirm_selections(mode, 'Are these selections correct?') + self.confirm_selections( + mode=mode, + prompt='Are these selections correct?', + source_parts=source_parts, + ) # Set working dir working_dir = get_working_dir(mode, self.destination)