Fix retry option and settings sections
This commit is contained in:
parent
8461e581ea
commit
7d30a735fc
1 changed files with 30 additions and 41 deletions
|
|
@ -17,15 +17,15 @@ AUTO_PASS_1_THRESHOLD = 95
|
||||||
AUTO_PASS_2_THRESHOLD = 98
|
AUTO_PASS_2_THRESHOLD = 98
|
||||||
DDRESCUE_SETTINGS = {
|
DDRESCUE_SETTINGS = {
|
||||||
'--binary-prefixes': {'Enabled': True, 'Hidden': True},
|
'--binary-prefixes': {'Enabled': True, 'Hidden': True},
|
||||||
'--data-preview': {'Enabled': True, 'Hidden': True},
|
'--data-preview': {'Enabled': True, 'Hidden': True, 'Value': '5'},
|
||||||
'--idirect': {'Enabled': True},
|
'--idirect': {'Enabled': True},
|
||||||
'--odirect': {'Enabled': True},
|
'--odirect': {'Enabled': True},
|
||||||
'--max-read-rate': {'Enabled': False, 'Value': '32MiB'},
|
'--max-read-rate': {'Enabled': False, 'Value': '32MiB'},
|
||||||
'--min-read-rate': {'Enabled': True, 'Value': '64KiB'},
|
'--min-read-rate': {'Enabled': True, 'Value': '64KiB'},
|
||||||
'--reopen-on-error': {'Enabled': True},
|
'--reopen-on-error': {'Enabled': True},
|
||||||
'--retry-passes=': {'Enabled': True, 'Value': '0'},
|
'--retry-passes': {'Enabled': True, 'Value': '0'},
|
||||||
'--test-mode=': {'Enabled': False, 'Value': 'test.map'},
|
'--test-mode': {'Enabled': False, 'Value': 'test.map'},
|
||||||
'--timeout=': {'Enabled': True, 'Value': '5m'},
|
'--timeout': {'Enabled': True, 'Value': '5m'},
|
||||||
'-vvvv': {'Enabled': True, 'Hidden': True},
|
'-vvvv': {'Enabled': True, 'Hidden': True},
|
||||||
}
|
}
|
||||||
RECOMMENDED_FSTYPES = ['ext3', 'ext4', 'xfs']
|
RECOMMENDED_FSTYPES = ['ext3', 'ext4', 'xfs']
|
||||||
|
|
@ -90,7 +90,10 @@ class BlockPair():
|
||||||
if os.path.exists(self.map_path):
|
if os.path.exists(self.map_path):
|
||||||
self.load_map_data()
|
self.load_map_data()
|
||||||
self.resumed = True
|
self.resumed = True
|
||||||
# Fix status strings
|
fix_status_strings()
|
||||||
|
|
||||||
|
def fix_status_strings(self):
|
||||||
|
"""Format status strings via get_formatted_status()."""
|
||||||
for pass_num in [1, 2, 3]:
|
for pass_num in [1, 2, 3]:
|
||||||
self.status[pass_num-1] = get_formatted_status(
|
self.status[pass_num-1] = get_formatted_status(
|
||||||
label='Pass {}'.format(pass_num),
|
label='Pass {}'.format(pass_num),
|
||||||
|
|
@ -329,6 +332,15 @@ class RecoveryState():
|
||||||
min_percent = min(min_percent, bp.rescued)
|
min_percent = min(min_percent, bp.rescued)
|
||||||
return min_percent
|
return min_percent
|
||||||
|
|
||||||
|
def retry_all_passes(self):
|
||||||
|
"""Mark all passes as pending for all block-pairs."""
|
||||||
|
self.current_pass = 0
|
||||||
|
for bp in self.block_pairs:
|
||||||
|
bp.pass_done = [False, False, False]
|
||||||
|
bp.status = ['Pending', 'Pending', 'Pending']
|
||||||
|
bp.fix_status_strings()
|
||||||
|
self.set_pass_num()
|
||||||
|
|
||||||
def self_checks(self):
|
def self_checks(self):
|
||||||
"""Run self-checks for each BlockPair and update state values."""
|
"""Run self-checks for each BlockPair and update state values."""
|
||||||
self.total_size = 0
|
self.total_size = 0
|
||||||
|
|
@ -595,18 +607,6 @@ def is_writable_filesystem(dir_obj):
|
||||||
return 'rw' in dir_obj.details.get('options', '')
|
return 'rw' in dir_obj.details.get('options', '')
|
||||||
|
|
||||||
|
|
||||||
def mark_all_passes_pending(source):
|
|
||||||
"""Mark all devs and passes as pending in preparation for retry."""
|
|
||||||
source['Current Pass'] = 'Pass 1'
|
|
||||||
source['Started Recovery'] = False
|
|
||||||
for p_num in ['Pass 1', 'Pass 2', 'Pass 3']:
|
|
||||||
source[p_num]['Status'] = 'Pending'
|
|
||||||
source[p_num]['Done'] = False
|
|
||||||
for child in source['Children']:
|
|
||||||
child[p_num]['Status'] = 'Pending'
|
|
||||||
child[p_num]['Done'] = False
|
|
||||||
|
|
||||||
|
|
||||||
def menu_ddrescue(source_path, dest_path, run_mode):
|
def menu_ddrescue(source_path, dest_path, run_mode):
|
||||||
"""ddrescue menu."""
|
"""ddrescue menu."""
|
||||||
source = None
|
source = None
|
||||||
|
|
@ -698,25 +698,22 @@ def menu_main(state):
|
||||||
main_options[index]['Enabled'] = not main_options[index]['Enabled']
|
main_options[index]['Enabled'] = not main_options[index]['Enabled']
|
||||||
elif selection == 'S':
|
elif selection == 'S':
|
||||||
# Set settings for pass
|
# Set settings for pass
|
||||||
settings = []
|
pass_settings = []
|
||||||
for k, v in state.settings.items():
|
for k, v in state.settings.items():
|
||||||
if not v['Enabled']:
|
if not v['Enabled']:
|
||||||
continue
|
continue
|
||||||
if k[-1:] == '=':
|
if 'Value' in v:
|
||||||
settings.append('{}{}'.format(k, v['Value']))
|
pass_settings.append('{}={}'.format(k, v['Value']))
|
||||||
else:
|
else:
|
||||||
settings.append(k)
|
pass_settings.append(k)
|
||||||
if 'Value' in v:
|
|
||||||
settings.append(v['Value'])
|
|
||||||
for opt in main_options:
|
for opt in main_options:
|
||||||
if 'Auto' in opt['Base Name']:
|
if 'Auto' in opt['Base Name']:
|
||||||
auto_run = opt['Enabled']
|
auto_run = opt['Enabled']
|
||||||
if 'Retry' in opt['Base Name'] and opt['Enabled']:
|
if 'Retry' in opt['Base Name'] and opt['Enabled']:
|
||||||
settings.extend(['--retrim', '--try-again'])
|
pass_settings.extend(['--retrim', '--try-again'])
|
||||||
mark_all_passes_pending(source)
|
state.retry_all_passes()
|
||||||
current_pass = 'Pass 1'
|
|
||||||
if 'Reverse' in opt['Base Name'] and opt['Enabled']:
|
if 'Reverse' in opt['Base Name'] and opt['Enabled']:
|
||||||
settings.append('--reverse')
|
pass_settings.append('--reverse')
|
||||||
# Disable for next pass
|
# Disable for next pass
|
||||||
if 'Auto' not in opt['Base Name']:
|
if 'Auto' not in opt['Base Name']:
|
||||||
opt['Enabled'] = False
|
opt['Enabled'] = False
|
||||||
|
|
@ -725,7 +722,7 @@ def menu_main(state):
|
||||||
state.started = False
|
state.started = False
|
||||||
while auto_run or not state.started:
|
while auto_run or not state.started:
|
||||||
state.started = True
|
state.started = True
|
||||||
run_ddrescue(state)
|
run_ddrescue(state, pass_settings)
|
||||||
if state.finished or not auto_run:
|
if state.finished or not auto_run:
|
||||||
break
|
break
|
||||||
if state.current_pass_done():
|
if state.current_pass_done():
|
||||||
|
|
@ -763,7 +760,7 @@ def menu_settings(state):
|
||||||
settings = []
|
settings = []
|
||||||
for k, v in sorted(state.settings.items()):
|
for k, v in sorted(state.settings.items()):
|
||||||
if not v.get('Hidden', False):
|
if not v.get('Hidden', False):
|
||||||
settings.append({'Base Name': k.replace('=', ''), 'Flag': k})
|
settings.append({'Base Name': k, 'Flag': k})
|
||||||
actions = [{'Name': 'Main Menu', 'Letter': 'M'}]
|
actions = [{'Name': 'Main Menu', 'Letter': 'M'}]
|
||||||
|
|
||||||
# Show menu
|
# Show menu
|
||||||
|
|
@ -835,7 +832,7 @@ def read_map_file(map_path):
|
||||||
return map_data
|
return map_data
|
||||||
|
|
||||||
|
|
||||||
def run_ddrescue(state):
|
def run_ddrescue(state, pass_settings):
|
||||||
"""Run ddrescue pass."""
|
"""Run ddrescue pass."""
|
||||||
return_code = None
|
return_code = None
|
||||||
|
|
||||||
|
|
@ -867,17 +864,9 @@ def run_ddrescue(state):
|
||||||
update_progress(state)
|
update_progress(state)
|
||||||
|
|
||||||
# Set ddrescue cmd
|
# Set ddrescue cmd
|
||||||
cmd = ['ddrescue', bp.source_path, bp.dest_path, bp.map_path]
|
cmd = [
|
||||||
for k, v in state.settings.items():
|
'ddrescue', *pass_settings,
|
||||||
if not v['Enabled']:
|
bp.source_path, bp.dest_path, bp.map_path]
|
||||||
continue
|
|
||||||
if 'Value' in v:
|
|
||||||
cmd.append('{}{}{}'.format(
|
|
||||||
k,
|
|
||||||
'' if k[-1:] == '=' else ' ',
|
|
||||||
v['Value']))
|
|
||||||
else:
|
|
||||||
cmd.append(k)
|
|
||||||
if state.mode == 'clone':
|
if state.mode == 'clone':
|
||||||
cmd.append('--force')
|
cmd.append('--force')
|
||||||
if state.current_pass == 0:
|
if state.current_pass == 0:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue