Moved menu_ddrescue() to ddrescue-tui-menu file
* Let's parse the sys.argv earlier in the process
This commit is contained in:
parent
fa3b3b11b0
commit
98b05c93bf
2 changed files with 27 additions and 31 deletions
|
|
@ -16,9 +16,29 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
# Prep
|
# Prep
|
||||||
clear_screen()
|
clear_screen()
|
||||||
|
args = list(sys.argv)
|
||||||
|
run_mode = ''
|
||||||
|
source_path = None
|
||||||
|
dest_path = None
|
||||||
|
|
||||||
# Show menu
|
# Parse args
|
||||||
menu_ddrescue(*sys.argv)
|
try:
|
||||||
|
script_name = os.path.basename(args.pop(0))
|
||||||
|
run_mode = str(args.pop(0)).lower()
|
||||||
|
source_path = args.pop(0)
|
||||||
|
dest_path = args.pop(0)
|
||||||
|
except IndexError:
|
||||||
|
# We'll set the missing paths later
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Show usage?
|
||||||
|
if run_mode in ('clone', 'image'):
|
||||||
|
menu_ddrescue(source_path, dest_path, run_mode)
|
||||||
|
else:
|
||||||
|
if not re.search(r'(^$|help|-h|\?)', run_mode, re.IGNORECASE):
|
||||||
|
print_error('Invalid mode.')
|
||||||
|
show_usage(script_name)
|
||||||
|
exit_script()
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
print_standard('\nDone.')
|
print_standard('\nDone.')
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class BlockPair():
|
||||||
self.status[pass_num] = get_formatted_status(100)
|
self.status[pass_num] = get_formatted_status(100)
|
||||||
# Mark future passes as Skipped
|
# Mark future passes as Skipped
|
||||||
pass_num += 1
|
pass_num += 1
|
||||||
while pass_num <= 2
|
while pass_num <= 2:
|
||||||
self.status[pass_num] = 'Skipped'
|
self.status[pass_num] = 'Skipped'
|
||||||
pass_num += 1
|
pass_num += 1
|
||||||
else:
|
else:
|
||||||
|
|
@ -446,35 +446,11 @@ def menu_clone(source_path, dest_path):
|
||||||
exit_script()
|
exit_script()
|
||||||
|
|
||||||
|
|
||||||
def menu_ddrescue(*args):
|
def menu_ddrescue(source_path, dest_path, run_mode):
|
||||||
"""Main ddrescue loop/menu."""
|
"""Main ddrescue menu."""
|
||||||
args = list(args)
|
# TODO Merge menu_clone and menu_image here
|
||||||
script_name = os.path.basename(args.pop(0))
|
|
||||||
run_mode = ''
|
|
||||||
source_path = None
|
|
||||||
dest_path = None
|
|
||||||
|
|
||||||
# Parse args
|
|
||||||
try:
|
|
||||||
run_mode = args.pop(0)
|
|
||||||
source_path = args.pop(0)
|
|
||||||
dest_path = args.pop(0)
|
|
||||||
except IndexError:
|
|
||||||
# We'll set the missing paths later
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Show proper menu or exit
|
|
||||||
if run_mode == 'clone':
|
|
||||||
menu_clone(source_path, dest_path)
|
|
||||||
elif run_mode == 'image':
|
|
||||||
menu_image(source_path, dest_path)
|
|
||||||
else:
|
|
||||||
if not re.search(r'(^$|help|-h|\?)', run_mode, re.IGNORECASE):
|
|
||||||
print_error('Invalid mode.')
|
|
||||||
show_usage(script_name)
|
|
||||||
exit_script()
|
|
||||||
|
|
||||||
|
|
||||||
def menu_image(source_path, dest_path):
|
def menu_image(source_path, dest_path):
|
||||||
"""ddrescue imaging menu."""
|
"""ddrescue imaging menu."""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue