def run_testing(dsr, msg, destinations): global RUN_TESTING while RUN_TESTING == True: for dst in destinations: dsr.send_message( hostname + "#Test Message to " + dst + " from " + str(node_id), dst) time.sleep(1)
def run_testing(dsr, msg, destinations): global RUN_TESTING while RUN_TESTING == True: for dst in destinations: dsr.send_message(hostname + "#Test Message to " + dst + " from " + str(node_id), dst) time.sleep(1)
print_help() try: if input_tokens[0] == "run": if input_tokens[1] == "test": length = len(input_tokens) ids_to_send_to = [] #ensure our input is good. try: #not the best, but allows me to check input before processing. for i in range (2, length): val = int(input_tokens[i]) for k in range (2, length): dsr.send_message(hostname + "#Test Message to " + input_tokens[k], input_tokens[k]) log_message("Send Test message to " + str(input_tokens[k])) ids_to_send_to.append(input_tokens[k]) if RUN_TESTING == True: msg = hostname + "#Test Message to " + str(input_tokens[k]) testing_thread = threading.Thread(target=run_testing, args=(dsr, msg, ids_to_send_to)) testing_thread.daemon = True testing_thread.start() except ValueError: log_message("Input not a valid node ID") if input_tokens[1] == "send": quote_tokens = user_input.split('"')
try: if input_tokens[0] == "run": if input_tokens[1] == "test": length = len(input_tokens) ids_to_send_to = [] #ensure our input is good. try: #not the best, but allows me to check input before processing. for i in range(2, length): val = int(input_tokens[i]) for k in range(2, length): dsr.send_message( hostname + "#Test Message to " + input_tokens[k], input_tokens[k]) log_message("Send Test message to " + str(input_tokens[k])) ids_to_send_to.append(input_tokens[k]) if RUN_TESTING == True: msg = hostname + "#Test Message to " + str( input_tokens[k]) testing_thread = threading.Thread( target=run_testing, args=(dsr, msg, ids_to_send_to)) testing_thread.daemon = True testing_thread.start() except ValueError: