def auto_run(filename): global CONF, AUTO_RUN_SCRIPT_FILES path = AUTO_RUN_SCRIPT_FILES[filename] file = open(path, "r") for line in file: # skip blank lines if not line.strip(): continue # ignore comment if line.startswith("#"): continue # print line line = line.rstrip() if line.startswith("CONF"): tokens = line.split(' ') CONF[tokens[1]] = { "role": tokens[2], "IP": tokens[3], "Port": tokens[4] } file.close() print "LAUNCHING ALL PROCESSES" for player in CONF: addr = CONF[player] os.system("python ../simulation/simulator.py " + addr["IP"] + " " + addr["Port"] + " " + MASTER_IP + " " + str(MASTER_PORT) + " " + player + " &") sleep(2) # send orders print "SENDING COMMANDS" file = open(path, "r") #file = open("../auto_run_scripts/all_routes.txt", "r") for line in file: # skip blank lines if not line.strip(): continue # ignore comment if line.startswith("#"): continue # print line if line.startswith("CONF") == False: tokens = line.split(' ', 1) addr = CONF[tokens[0]] message = eval(tokens[1]) #if (message["action"] == "initialize"): # self.writeJsonFile(message["localName"], message["role"], "71A") ip = addr["IP"] port = int(addr["Port"]) TCPComm.send(ip, port, message)
def reporterThread(): global MASTER_IP, MASTER_PORT while True: state = host.state() if state != None: LOGGER.info("report state: %s" % state) TCPComm.send(MASTER_IP, MASTER_PORT, state) sleep(1)
def launchSimulator(simulatorName, role, ip, port, message): global CONF CONF[simulatorName] = {"role": role, "IP" : ip, "Port" : port} # launch simulator os.system("python ../simulation/simulator.py " + ip + " " + str(port) + " " + MASTER_IP + " " + str(MASTER_PORT) + " " + simulatorName + " &") sleep(2) # send initialize command TCPComm.send(ip, port, message)
def launchSimulator(simulatorName, role, ip, port, message): global CONF CONF[simulatorName] = {"role": role, "IP": ip, "Port": port} # launch simulator os.system("python ../simulation/simulator.py " + ip + " " + str(port) + " " + MASTER_IP + " " + str(MASTER_PORT) + " " + simulatorName + " &") sleep(2) # send initialize command TCPComm.send(ip, port, message)
def auto_run(filename): global CONF, AUTO_RUN_SCRIPT_FILES path = AUTO_RUN_SCRIPT_FILES[filename] file = open(path, "r") for line in file: # skip blank lines if not line.strip(): continue # ignore comment if line.startswith("#"): continue # print line line = line.rstrip() if line.startswith("CONF"): tokens = line.split(' ') CONF[tokens[1]] = {"role" : tokens[2], "IP" : tokens[3], "Port" : tokens[4]} file.close() print "LAUNCHING ALL PROCESSES" for player in CONF: addr = CONF[player] os.system("python ../simulation/simulator.py " + addr["IP"] + " " + addr["Port"] + " " + MASTER_IP + " " + str(MASTER_PORT) + " " + player + " &") sleep(2) # send orders print "SENDING COMMANDS" file = open(path, "r") #file = open("../auto_run_scripts/all_routes.txt", "r") for line in file: # skip blank lines if not line.strip(): continue # ignore comment if line.startswith("#"): continue # print line if line.startswith("CONF") == False: tokens = line.split(' ', 1) addr = CONF[tokens[0]] message = eval(tokens[1]) #if (message["action"] == "initialize"): # self.writeJsonFile(message["localName"], message["role"], "71A") ip = addr["IP"] port = int(addr["Port"]) TCPComm.send(ip, port, message)
def sendCmd(simulatorName, message): if CONF.has_key(simulatorName) == False: return addr = CONF[simulatorName] ip = addr["IP"] port = int(addr["Port"]) if message["action"] == "exit": CONF.pop(simulatorName) if len(CONF) == 0 or len(CONF) == 1: clearFiles() TCPComm.send(ip, port, message)
"DRIVER_2" : "127.0.0.1:9200", "DRIVER_3" : "127.0.0.1:9300", "USER_1" : "127.0.0.1:10000" ''' if __name__ == "__main__": file = open("../feedFile.txt", "r") for line in file: global CONF # skip blank lines if not line.strip(): continue # ignore comment if line.startswith("#"): continue # print line line = line.rstrip() if line.startswith("CONF"): tokens = line.split(' ') CONF[tokens[1]] = {"IP" : tokens[2], "Port" : tokens[3]} else: tokens = line.split(' ', 1) message = eval(tokens[1]) ip = CONF[tokens[0]]["IP"] port = int(CONF[tokens[0]]["Port"]) TCPComm.send(ip, port, message)
"GSN" : "127.0.0.1:9000", "DRIVER_1" : "127.0.0.1:9100", "DRIVER_2" : "127.0.0.1:9200", "DRIVER_3" : "127.0.0.1:9300", "USER_1" : "127.0.0.1:10000" ''' if __name__ == "__main__": file = open("../feedFile.txt", "r") for line in file: global CONF # skip blank lines if not line.strip(): continue # ignore comment if line.startswith("#"): continue # print line line = line.rstrip() if line.startswith("CONF"): tokens = line.split(' ') CONF[tokens[1]] = {"IP": tokens[2], "Port": tokens[3]} else: tokens = line.split(' ', 1) message = eval(tokens[1]) ip = CONF[tokens[0]]["IP"] port = int(CONF[tokens[0]]["Port"]) TCPComm.send(ip, port, message)