Added confirmation to Quit if recovery < 100%
This commit is contained in:
parent
848ccc3ef1
commit
4a2b18e4f7
1 changed files with 18 additions and 6 deletions
|
|
@ -498,7 +498,15 @@ class State():
|
||||||
if not std.ask(prompt):
|
if not std.ask(prompt):
|
||||||
raise std.GenericAbort()
|
raise std.GenericAbort()
|
||||||
|
|
||||||
|
def get_percent_recovered(self):
|
||||||
|
"""Get total percent rescued from block_pairs, returns float."""
|
||||||
|
total_rescued = self.get_rescued_size()
|
||||||
|
total_size = sum([pair.size for pair in self.block_pairs])
|
||||||
|
return 100 * total_rescued / total_size
|
||||||
|
|
||||||
|
def get_rescued_size(self):
|
||||||
|
"""Get total rescued size from all block pairs, returns int."""
|
||||||
|
return sum([pair.get_rescued_size() for pair in self.block_pairs])
|
||||||
|
|
||||||
def init_recovery(self, docopt_args):
|
def init_recovery(self, docopt_args):
|
||||||
"""Select source/dest and set env."""
|
"""Select source/dest and set env."""
|
||||||
|
|
@ -870,11 +878,8 @@ class State():
|
||||||
|
|
||||||
# Overall progress
|
# Overall progress
|
||||||
if self.block_pairs:
|
if self.block_pairs:
|
||||||
total_rescued = sum(
|
total_rescued = self.get_rescued_size()
|
||||||
[pair.map_data.get('rescued', 0) for pair in self.block_pairs],
|
percent = self.get_percent_recovered()
|
||||||
)
|
|
||||||
total_size = sum([pair.size for pair in self.block_pairs])
|
|
||||||
percent = 100 * total_rescued / total_size
|
|
||||||
report.append(std.color_string('Overall Progress', 'BLUE'))
|
report.append(std.color_string('Overall Progress', 'BLUE'))
|
||||||
report.append(
|
report.append(
|
||||||
f'Rescued: {format_status_string(percent, width=width-9)}',
|
f'Rescued: {format_status_string(percent, width=width-9)}',
|
||||||
|
|
@ -1574,7 +1579,14 @@ def main():
|
||||||
|
|
||||||
# Quit
|
# Quit
|
||||||
if 'Quit' in selection:
|
if 'Quit' in selection:
|
||||||
break
|
total_percent = state.get_percent_recovered()
|
||||||
|
if total_percent == 100:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Recovey < 100%
|
||||||
|
std.print_warning('Recovery is less than 100%')
|
||||||
|
if std.ask('Are you sure you want to quit?'):
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def mount_raw_image(path):
|
def mount_raw_image(path):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue