From 294bcbaa45ac3be1f245aa2ef27ce39007db79bd Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 4 Jul 2018 23:20:17 -0500 Subject: [PATCH 1/6] prompt-toolkit has been updated many times since slcli-shell was created. p_shortcuts.prompt() passed arguments that are long deprecated causing the shell to fail. --- SoftLayer/shell/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SoftLayer/shell/core.py b/SoftLayer/shell/core.py index f90064ba5..e6ee6151b 100644 --- a/SoftLayer/shell/core.py +++ b/SoftLayer/shell/core.py @@ -69,15 +69,14 @@ def get_prompt_tokens(_): tokens.append((token.Token.Prompt, '> ')) return tokens - try: line = p_shortcuts.prompt( completer=complete, - history=history, + complete_while_typing=True, auto_suggest=p_auto_suggest.AutoSuggestFromHistory(), - get_prompt_tokens=get_prompt_tokens, ) + # Parse arguments try: args = shlex.split(line) From 1f44e7d35a68a7e30d2acffb3210cc4a64e5a4ff Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 4 Jul 2018 23:51:20 -0500 Subject: [PATCH 2/6] resolve pep E303 --- SoftLayer/shell/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/SoftLayer/shell/core.py b/SoftLayer/shell/core.py index e6ee6151b..7c1930647 100644 --- a/SoftLayer/shell/core.py +++ b/SoftLayer/shell/core.py @@ -76,7 +76,6 @@ def get_prompt_tokens(_): auto_suggest=p_auto_suggest.AutoSuggestFromHistory(), ) - # Parse arguments try: args = shlex.split(line) From fea967b5e4af8a49d746e92d58c71b13fbb91d5b Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 4 Jul 2018 23:53:31 -0500 Subject: [PATCH 3/6] removed unused variable. --- SoftLayer/shell/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/SoftLayer/shell/core.py b/SoftLayer/shell/core.py index 7c1930647..3bd594d7b 100644 --- a/SoftLayer/shell/core.py +++ b/SoftLayer/shell/core.py @@ -49,7 +49,6 @@ def cli(ctx, env): app_path = click.get_app_dir('softlayer_shell') if not os.path.exists(app_path): os.makedirs(app_path) - history = p_history.FileHistory(os.path.join(app_path, 'history')) complete = completer.ShellCompleter(core.cli) while True: From 227766e6683db451940878a6b2876f82b8d78754 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 5 Jul 2018 00:00:03 -0500 Subject: [PATCH 4/6] removed unused variables. --- SoftLayer/shell/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/SoftLayer/shell/core.py b/SoftLayer/shell/core.py index 3bd594d7b..a55103e7b 100644 --- a/SoftLayer/shell/core.py +++ b/SoftLayer/shell/core.py @@ -14,7 +14,6 @@ import click from prompt_toolkit import auto_suggest as p_auto_suggest -from prompt_toolkit import history as p_history from prompt_toolkit import shortcuts as p_shortcuts from pygments import token From 7b5080ea3aaa90563bcfecfbcc6e53a6ba44a3f2 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 5 Jul 2018 16:43:31 -0500 Subject: [PATCH 5/6] removed get_prompt_tokens. --- SoftLayer/shell/core.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/SoftLayer/shell/core.py b/SoftLayer/shell/core.py index a55103e7b..7c19f4dfd 100644 --- a/SoftLayer/shell/core.py +++ b/SoftLayer/shell/core.py @@ -51,22 +51,6 @@ def cli(ctx, env): complete = completer.ShellCompleter(core.cli) while True: - def get_prompt_tokens(_): - """Returns tokens for the command prompt""" - tokens = [] - try: - tokens.append((token.Token.Username, env.client.auth.username)) - tokens.append((token.Token.At, "@")) - except AttributeError: - pass - - tokens.append((token.Token.Host, "slcli-shell")) - if env.vars['last_exit_code']: - tokens.append((token.Token.ErrorPrompt, '> ')) - else: - tokens.append((token.Token.Prompt, '> ')) - - return tokens try: line = p_shortcuts.prompt( completer=complete, From 1a46b24fe6d1b8b74eab2c460ad1f04da9e59027 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 5 Jul 2018 16:46:26 -0500 Subject: [PATCH 6/6] removed pygments import. --- SoftLayer/shell/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/SoftLayer/shell/core.py b/SoftLayer/shell/core.py index 7c19f4dfd..ed90f9c95 100644 --- a/SoftLayer/shell/core.py +++ b/SoftLayer/shell/core.py @@ -15,7 +15,6 @@ import click from prompt_toolkit import auto_suggest as p_auto_suggest from prompt_toolkit import shortcuts as p_shortcuts -from pygments import token from SoftLayer.CLI import core from SoftLayer.CLI import environment