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:
|
||||
# Prep
|
||||
clear_screen()
|
||||
args = list(sys.argv)
|
||||
run_mode = ''
|
||||
source_path = None
|
||||
dest_path = None
|
||||
|
||||
# Show menu
|
||||
menu_ddrescue(*sys.argv)
|
||||
# Parse args
|
||||
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
|
||||
print_standard('\nDone.')
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class BlockPair():
|
|||
self.status[pass_num] = get_formatted_status(100)
|
||||
# Mark future passes as Skipped
|
||||
pass_num += 1
|
||||
while pass_num <= 2
|
||||
while pass_num <= 2:
|
||||
self.status[pass_num] = 'Skipped'
|
||||
pass_num += 1
|
||||
else:
|
||||
|
|
@ -446,34 +446,10 @@ def menu_clone(source_path, dest_path):
|
|||
exit_script()
|
||||
|
||||
|
||||
def menu_ddrescue(*args):
|
||||
"""Main ddrescue loop/menu."""
|
||||
args = list(args)
|
||||
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
|
||||
|
||||
# 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_ddrescue(source_path, dest_path, run_mode):
|
||||
"""Main ddrescue menu."""
|
||||
# TODO Merge menu_clone and menu_image here
|
||||
pass
|
||||
|
||||
def menu_image(source_path, dest_path):
|
||||
"""ddrescue imaging menu."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue