Skip to content

Commit

Permalink
Tweaks to prompt user for cancel.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankD412 committed Jan 30, 2021
1 parent 6774b61 commit d2a1d9f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions maestrowf/maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,31 @@ def cancel_study(args):
directory_list = args.directory

ret_code = 0
to_cancel = []
if directory_list:
for directory in directory_list:
if not os.path.isdir(directory):
abs_path = os.path.abspath(directory)
if not os.path.isdir(abs_path):
print(
f"Attempted to cancel '{directory}' "
f"Attempted to cancel '{abs_path}' "
"-- study directory not found.")
ret_code = 2
ret_code = 1
else:
print(f"Marked study in '{directory}' to be cancelled.")
Conductor.mark_cancelled(directory)
print(f"Study in '{abs_path}' to be cancelled.")
to_cancel.append(abs_path)

if to_cancel:
ok_cancel = input("Are you sure? [y|[n]]: ")
try:
if ok_cancel in ACCEPTED_INPUT:
for directory in to_cancel:
Conductor.mark_cancelled(directory)
except Exception as excpt:
print(f"Error:\n{excpt}")
print("Error in cancellation. Aborting.")
return -1
else:
print("Cancellation aborted.")
else:
print("Path(s) or glob(s) did not resolve to a directory(ies).")
ret_code = 1
Expand Down

0 comments on commit d2a1d9f

Please sign in to comment.