From 5985587b4a10a089fb72e9194b8ad71e90021bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 2 Jan 2019 17:07:46 +0100 Subject: [PATCH] offer choices when a command fails --- eoptasks.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/eoptasks.py b/eoptasks.py index 3ab8e76..492f8d0 100755 --- a/eoptasks.py +++ b/eoptasks.py @@ -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()