def send_command(command): client = connect_client_socket() client.send(pickle.dumps(command, -1)) answer = client.recv(1048576) response = pickle.loads(answer) client.close() return response
def get_status(): # Initialize socket, message and send it client = connect_client_socket() instruction = {'mode': 'status'} data_string = pickle.dumps(instruction, -1) client.send(data_string) response = receive_data(client) return response
def change_state(instruction): # Initialize socket, message and send it client = connect_client_socket() instruction['mode'] = state instruction['func'] = None data_string = pickle.dumps(instruction, -1) client.send(data_string) # Receive message and print it response = receive_data(client) process_response(response)
def execute_send(args): client = connect_client_socket() # Send new instruction to daemon instruction = {"mode": "send", "input": args["input"]} data_string = pickle.dumps(instruction, -1) client.send(data_string) # Receive Answer from daemon and print it response = receive_data(client) process_response(response)
def execute_add(args): client = connect_client_socket() # Send new instruction to daemon instruction = {"mode": "add", "command": args["command"], "path": os.getcwd()} data_string = pickle.dumps(instruction, -1) client.send(data_string) # Receive Answer from daemon and print it response = receive_data(client) process_response(response)