More comments and fixes
This commit is contained in:
parent
8ec78fd01b
commit
6cff08ce3d
1 changed files with 11 additions and 12 deletions
|
@ -55,24 +55,22 @@ def create_server():
|
||||||
servers = servers + new_server # Append new array to existing array.
|
servers = servers + new_server # Append new array to existing array.
|
||||||
write_servers() # Write to the file.
|
write_servers() # Write to the file.
|
||||||
|
|
||||||
|
# Used to delete servers from the array and write.
|
||||||
def pop_server():
|
def pop_server():
|
||||||
global servers
|
global servers # Global so we can write
|
||||||
print('\n=== Remove Server ===\nPick a server to delete')
|
print('\n=== Remove Server ===\nPick a server to delete')
|
||||||
list_servers(2)
|
list_servers(2) # Lists server ID and Name only.
|
||||||
delete = int(input('?: '))
|
delete = int(input('?: '))
|
||||||
|
|
||||||
servers.pop(delete)
|
servers.pop(delete)
|
||||||
|
|
||||||
write_servers()
|
write_servers()
|
||||||
|
|
||||||
initial_choice()
|
# Let's send some commands to the servers!
|
||||||
|
|
||||||
def send_commands():
|
def send_commands():
|
||||||
proceed=True
|
proceed=True # Used in while loops to determine if we still want to send more commands.
|
||||||
print('\n=== Send commands ===')
|
print('\n=== Send commands ===')
|
||||||
choice = int(input('Single Server (1) or All (2)?: '))
|
choice = int(input('Single Server (1) or All (2)?: '))
|
||||||
if(choice==1):
|
if(choice==1): # We only want to interact with one server.
|
||||||
list_servers(2)
|
list_servers(2) # Show us which servers we can pick from.
|
||||||
server = int(input('Server?: '))
|
server = int(input('Server?: '))
|
||||||
while(proceed):
|
while(proceed):
|
||||||
command = input('Input command (None to exit): ')
|
command = input('Input command (None to exit): ')
|
||||||
|
@ -84,11 +82,10 @@ def send_commands():
|
||||||
else:
|
else:
|
||||||
proceed = False
|
proceed = False
|
||||||
print('No command was entered. Exiting.\n')
|
print('No command was entered. Exiting.\n')
|
||||||
initial_choice()
|
|
||||||
elif(choice==2):
|
elif(choice==2):
|
||||||
while(proceed):
|
while(proceed):
|
||||||
command = input('Input command (None to exit): ')
|
command = input('Input command (None to exit): ')
|
||||||
for x in servers:
|
for x in servers: # Run for each server.
|
||||||
if(command!=""):
|
if(command!=""):
|
||||||
with Client(x['address'], int(x['port']), passwd=x['password']) as client:
|
with Client(x['address'], int(x['port']), passwd=x['password']) as client:
|
||||||
response = client.run(command)
|
response = client.run(command)
|
||||||
|
@ -97,8 +94,8 @@ def send_commands():
|
||||||
else:
|
else:
|
||||||
proceed = False
|
proceed = False
|
||||||
print('No command was entered. Exiting.\n')
|
print('No command was entered. Exiting.\n')
|
||||||
initial_choice()
|
|
||||||
|
|
||||||
|
# The main menu.
|
||||||
def initial_choice():
|
def initial_choice():
|
||||||
choose_func = input('=== Choose Function ===\n1. Add servers\n2. Remove servers\n3. List servers\n4. Send commands\n5. Exit\n?: ')
|
choose_func = input('=== Choose Function ===\n1. Add servers\n2. Remove servers\n3. List servers\n4. Send commands\n5. Exit\n?: ')
|
||||||
|
|
||||||
|
@ -108,11 +105,13 @@ def initial_choice():
|
||||||
initial_choice()
|
initial_choice()
|
||||||
case "2":
|
case "2":
|
||||||
pop_server()
|
pop_server()
|
||||||
|
initial_choice()
|
||||||
case "3":
|
case "3":
|
||||||
list_servers()
|
list_servers()
|
||||||
initial_choice()
|
initial_choice()
|
||||||
case "4":
|
case "4":
|
||||||
send_commands()
|
send_commands()
|
||||||
|
initial_choice()
|
||||||
case "5":
|
case "5":
|
||||||
exit()
|
exit()
|
||||||
case _:
|
case _:
|
||||||
|
|
Loading…
Reference in a new issue