Moved block pair report to new function

This commit is contained in:
2Shirt 2019-12-24 16:42:18 -07:00
parent e7e3261b0a
commit 67bb9223aa
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -221,8 +221,7 @@ class State():
else: else:
# New run and new settings # New run and new settings
offset = 0 offset = 0
if (std.ask('Does the source disk contain an OS?') if std.ask('Create an empty Windows boot partition on the clone?'):
and std.ask('Create an empty boot partition on the clone?')):
offset = 2 offset = 2
settings['Needs Format'] = True settings['Needs Format'] = True
settings['Table Type'] = 'GPT' settings['Table Type'] = 'GPT'
@ -256,7 +255,8 @@ class State():
bp_dest = self.destination bp_dest = self.destination
self.add_block_pair(part, bp_dest, working_dir) self.add_block_pair(part, bp_dest, working_dir)
def confirm_selections(self, mode, prompt, map_dir=None, source_parts=None): def confirm_selections(
self, mode, prompt, working_dir=None, source_parts=None):
"""Show selection details and prompt for confirmation.""" """Show selection details and prompt for confirmation."""
report = [] report = []
@ -290,19 +290,19 @@ class State():
# Block pairs # Block pairs
if self.block_pairs: if self.block_pairs:
report.append(std.color_string('Block Pairs', 'GREEN')) report.extend(
# TODO Move to separate function and include resume messages build_block_pair_report(
for pair in self.block_pairs: self.block_pairs,
# Show mapping self.load_settings(working_dir) if mode == 'Clone' else {},
report.append(f'{pair.source.name} --> {pair.destination.name}') ),
report.append(' ') )
# Map dir # Map dir
if map_dir: if working_dir:
report.append(std.color_string('Map Save Directory', 'GREEN')) report.append(std.color_string('Map Save Directory', 'GREEN'))
report.append(f'{map_dir}/') report.append(f'{working_dir}/')
report.append(' ') report.append(' ')
if not fstype_is_ok(map_dir, map_dir=True): if not fstype_is_ok(working_dir, map_dir=True):
report.append( report.append(
std.color_string( std.color_string(
'Map file(s) are being saved to a non-recommended filesystem.', 'Map file(s) are being saved to a non-recommended filesystem.',
@ -439,7 +439,7 @@ class State():
self.add_image_block_pairs(source_parts, working_dir) self.add_image_block_pairs(source_parts, working_dir)
# Confirmation #2 # Confirmation #2
self.confirm_selections(mode, 'Start recovery?', map_dir=working_dir) self.confirm_selections(mode, 'Start recovery?', working_dir=working_dir)
# Prep destination # Prep destination
# if cloning and not resuming format destination # if cloning and not resuming format destination
@ -598,6 +598,34 @@ class State():
# Functions # Functions
def build_block_pair_report(block_pairs, settings):
"""Build block pair report, returns list."""
report = []
if block_pairs:
report.append(std.color_string('Block Pairs', 'GREEN'))
else:
# Bail early
return report
# Show block pair mapping
if settings and settings['Needs Format']:
if settings['Table Type'] == 'GPT':
report.append(f'{" —— ":<9} --> EFI System Partition')
report.append(f'{" —— ":<9} --> Microsoft Reserved Partition')
elif settings['Table Type'] == 'MBR':
report.append(f'{" —— ":<9} --> System Reserved')
for pair in block_pairs:
report.append(f'{pair.source.name:<9} --> {pair.destination.name}')
report.append(' ')
# Show resume messages as necessary
# TODO If settings --> Add loaded settings msg
# TODO If anything recovered --> Add resume msg
# Done
return report
def build_directory_report(path): def build_directory_report(path):
"""Build directory report, returns list.""" """Build directory report, returns list."""
path = f'{path}/' path = f'{path}/'