From 81df9ef44374a99509ad5347bf3ca5214938988c Mon Sep 17 00:00:00 2001 From: Subnet_Masked Date: Sun, 4 Feb 2024 16:24:51 -0500 Subject: [PATCH] Implement sending commands to all severs --- mc_control.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mc_control.py b/mc_control.py index 387a4f9..3605e12 100644 --- a/mc_control.py +++ b/mc_control.py @@ -41,9 +41,9 @@ def list_servers(mode=int(1)): def create_server(isfirstrun=False): global servers if(isfirstrun): - print('!! Looks like you do not have any servers yet - Let\'s add one.\n') + print('\n!! Looks like you do not have any servers yet - Let\'s add one.\n') - print('=== Add Server ===') + print('\n=== Add Server ===') srv_name = input('Name: ') srv_addr = input('Address: ') srv_port = input('Port: ') @@ -62,7 +62,7 @@ def create_server(isfirstrun=False): def pop_server(): global servers - print('=== Remove Server ===\nPick a server to delete') + print('\n=== Remove Server ===\nPick a server to delete') list_servers(2) delete = int(input('?: ')) @@ -74,13 +74,13 @@ def pop_server(): def send_commands(): proceed=True - print('=== Send commands ===') + print('\n=== Send commands ===') choice = int(input('Single Server (1) or All (2)?: ')) if(choice==1): list_servers(2) server = int(input('Server?: ')) while(proceed): - command = input('Input command: ') + command = input('Input command (None to exit): ') if(command!=""): with Client(servers[server]['address'], int(servers[server]['port']), passwd=servers[server]['password']) as client: response = client.run(command) @@ -91,7 +91,18 @@ def send_commands(): print('No command was entered. Exiting.\n') initial_choice() elif(choice==2): - print('Would do every server') + while(proceed): + command = input('Input command (None to exit): ') + for x in servers: + if(command!=""): + with Client(x['address'], int(x['port']), passwd=x['password']) as client: + response = client.run(command) + + print(x['name']+': '+response) + else: + proceed = False + print('No command was entered. Exiting.\n') + 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?: ')