diff --git a/portainer.py b/portainer.py index 9b00666..9401118 100755 --- a/portainer.py +++ b/portainer.py @@ -20,11 +20,7 @@ from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter from prompt_toolkit.shortcuts import checkboxlist_dialog from prompt_toolkit.shortcuts import radiolist_dialog -from prompt_toolkit.application import Application -from prompt_toolkit.layout import Layout -from prompt_toolkit.widgets import RadioList -from prompt_toolkit.key_binding import KeyBindings -from prompt_toolkit.layout.containers import HSplit + VERSION = "0.1.3" defaults = { @@ -258,10 +254,13 @@ def prompt_missing_args(args_in, defaults_in, fields, action=None,stacks=None): 'node-red', 'octoprint', 'ollama', 'pihole', 'portainer-ce', 'rancher', 'registry', 'regsync', 'semaphore', 'unifibrowser', 'uptime-kuma', 'watchtower', 'wazuh', 'webhub', 'wud', 'zabbix-server'] - for s in por.all_data['stacks'][defaults_in[f"PORTAINER_ENDPOINT_ID".upper()]]['by_name'].keys(): + try: + for s in por.all_data['stacks'][defaults_in[f"PORTAINER_ENDPOINT_ID".upper()]]['by_name'].keys(): - # print(s) - commands.remove(s) + # print(s) + commands.remove(s) + except KeyError: + print("No stacks found for endpoint", defaults_in[f"PORTAINER_ENDPOINT_ID".upper()]) else: commands = [] @@ -366,6 +365,7 @@ def prompt_missing_args(args_in, defaults_in, fields, action=None,stacks=None): return args + if __name__ == "__main__": # Example usage: set PORTAINER_USER and PORTAINER_PASS in env, or pass literals below. # token = get_portainer_token(base,"admin","l4c1j4yd33Du5lo") # or get_portainer_token(base, "admin", "secret")