mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2025-12-14 18:44:53 +01:00
build
This commit is contained in:
83
portainer.py
83
portainer.py
@@ -38,88 +38,6 @@ defaults = {
|
|||||||
|
|
||||||
cur_config = {}
|
cur_config = {}
|
||||||
|
|
||||||
def menu(title, options):
|
|
||||||
"""
|
|
||||||
Display a menu and return selected value.
|
|
||||||
options must be list of (value, text) or text (auto-wrapped)
|
|
||||||
"""
|
|
||||||
if isinstance(options[0], str):
|
|
||||||
options = [(item, item) for item in options]
|
|
||||||
|
|
||||||
radio = RadioList(options)
|
|
||||||
|
|
||||||
kb = KeyBindings()
|
|
||||||
|
|
||||||
@kb.add("enter")
|
|
||||||
def _(event):
|
|
||||||
event.app.exit(result=radio.current_value)
|
|
||||||
@kb.add("q")
|
|
||||||
def _(event):
|
|
||||||
event.app.exit(result=None)
|
|
||||||
layout = Layout(HSplit([radio]))
|
|
||||||
|
|
||||||
app = Application(
|
|
||||||
layout=layout,
|
|
||||||
key_bindings=kb,
|
|
||||||
full_screen=True
|
|
||||||
)
|
|
||||||
|
|
||||||
return app.run()
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------
|
|
||||||
# MULTI-LEVEL MENU
|
|
||||||
# --------------------------
|
|
||||||
|
|
||||||
def main_menu():
|
|
||||||
while True:
|
|
||||||
choice = menu("Main Menu", [
|
|
||||||
"System",
|
|
||||||
"Network",
|
|
||||||
"Services",
|
|
||||||
"Exit"
|
|
||||||
])
|
|
||||||
|
|
||||||
if choice == "System":
|
|
||||||
system_menu()
|
|
||||||
|
|
||||||
elif choice == "Network":
|
|
||||||
network_menu()
|
|
||||||
|
|
||||||
elif choice == "Services":
|
|
||||||
services_menu()
|
|
||||||
|
|
||||||
elif choice == "Exit":
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def system_menu():
|
|
||||||
choice = menu("System Menu", [
|
|
||||||
"Info",
|
|
||||||
"Reboot",
|
|
||||||
"Back"
|
|
||||||
])
|
|
||||||
print("SYSTEM →", choice)
|
|
||||||
|
|
||||||
|
|
||||||
def network_menu():
|
|
||||||
choice = menu("Network Menu", [
|
|
||||||
"Show IP",
|
|
||||||
"Restart Networking",
|
|
||||||
"Back"
|
|
||||||
])
|
|
||||||
print("NETWORK →", choice)
|
|
||||||
|
|
||||||
|
|
||||||
def services_menu():
|
|
||||||
choice = menu("Services", [
|
|
||||||
"Start Service",
|
|
||||||
"Stop Service",
|
|
||||||
"Status",
|
|
||||||
"Back"
|
|
||||||
])
|
|
||||||
print("SERVICES →", choice)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(defaults=defaults):
|
def load_config(defaults=defaults):
|
||||||
@@ -455,7 +373,6 @@ if __name__ == "__main__":
|
|||||||
logger.warning("Killed manually %s, %s", sig, frame)
|
logger.warning("Killed manually %s, %s", sig, frame)
|
||||||
print("\nTerminated by user")
|
print("\nTerminated by user")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
main_menu()
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
os.system("cls" if os.name == "nt" else "clear")
|
os.system("cls" if os.name == "nt" else "clear")
|
||||||
if args.action is None:
|
if args.action is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user