monolith/legacy/commands/list.py

37 lines
1.3 KiB
Python
Raw Normal View History

import main
2022-08-11 18:22:09 +00:00
from modules import helpers
2022-07-21 12:39:41 +00:00
class ListCommand:
def __init__(self, *args):
self.list(*args)
def list(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:
if length == 1:
for i in main.network.keys():
2022-08-11 18:22:09 +00:00
first_relay = helpers.get_first_relay(i)
####
if not first_relay:
info("Network has no first instance: %s" % i)
continue
2022-08-11 18:22:09 +00:00
first_relay.list()
success(f"Requested list with instance {first_relay.num} of {i}")
return
elif length == 2:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
2022-08-11 18:22:09 +00:00
first_relay = helpers.get_first_relay(spl[1])
if not first_relay:
failure("Could not get first instance")
return
2022-08-11 18:22:09 +00:00
first_relay.list()
success(f"Requested list with instance {first_relay.num} of {spl[1]}")
return
else:
incUsage("list")
return
else:
incUsage(None)