eoptasks: offer choices when a command fails

This commit is contained in:
Frédéric Péters 2019-01-02 17:07:46 +01:00
parent 311e4e6983
commit ba350c8200
1 changed files with 17 additions and 3 deletions

View File

@ -216,12 +216,26 @@ def command_window(args):
}.get(args.cmd, args.cmd)
if args.args:
cmd += ' ' + ' '.join(['"%s"' % x for x in args.args])
rc = subprocess.call(['ssh', '-t', args.command_server_name] + [cmd])
if rc != 0:
orig_cmd = cmd
while True:
rc = subprocess.call(['ssh', '-t', args.command_server_name] + [cmd])
if rc == 0:
send_status_message(tmux_session_name,
{'@type': 'server-result',
'info': {args.command_server_name: 'success'}})
break
send_status_message(tmux_session_name,
{'@type': 'server-result',
'info': {args.command_server_name: 'error'}})
input('type enter to quit --> ')
choice = None
while choice not in ['r', 's', 'q']:
choice = input('[R]etry, [S]hell, [Q]uit --> ').lower()
if choice == 'r':
cmd = orig_cmd
elif choice == 's':
cmd = 'bash'
elif choice == 'q':
break
args = parse_args()