From: Marius Sandu-Popa Date: Thu, 15 Apr 2010 11:15:48 +0000 (+0300) Subject: updated Util with SERVER globals X-Git-Tag: getopt_long~82 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=3be9a9b9e69215d4fadad2358eb4aa27ced7e756;p=cs-p2p-next.git updated Util with SERVER globals --- diff --git a/autorun/Util.py b/autorun/Util.py index 10a4128..9624d81 100644 --- a/autorun/Util.py +++ b/autorun/Util.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +SERVER_DIR = "/home/p2p/cs-p2p-next/autorun/server/" +SERVER_FILE = "Server.py" +SERVER_TYPE = "python" SERVER_PORT = 10004 #SERVER_HOST = "127.0.0.1" SERVER_HOST = "172.16.20.3" diff --git a/autorun/commander/Commander.py b/autorun/commander/Commander.py index 83effec..a1b4a4f 100644 --- a/autorun/commander/Commander.py +++ b/autorun/commander/Commander.py @@ -45,13 +45,11 @@ class Commander(Thread): def sendComm(self, hostname, port, msg_type, config_data): try: self.sock.connect((hostname, port)) - self.sendMsg(msg_type) + self.sendMsg(pickle.dumps((msg_type, config_data))) response = self.recvMsg() - if response == ACK_MSG: - self.sendMsg(pickle.dumps(config_data)) - response = self.recvMsg() - print "->>>>>>>>>>>>>>>>>>>>>>>>>", response + return response except Exception, e: + print "Ups: Could not complete request" print e finally: self.sock.close() @@ -75,21 +73,26 @@ class Commander(Thread): def startDaemon(self, node): print node.daemon_dir - comm = "python " + node.daemon_dir + "Server.py start " + node.public_address + " " + node.listen_port + comm = SERVER_TYPE+ " "+SERVER_DIR+ " "+SERVER_FILE+" "+"start" + #+ node.public_address + " " + node.listen_port print comm #self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, comm) - self.sendSSHComm(node.public_address, node.username, int(node.ssh_port), comm) - self.sendSSHComm(node.public_address, node.username, int(node.ssh_port), "ps -ef | grep Server") + #self.sendSSHComm(node.public_address, node.username, int(node.ssh_port), comm) + #self.sendSSHComm(node.public_address, node.username, int(node.ssh_port), "ps -ef | grep Server") def applyTC(self, node): si = self.swarm.getSIByNode(node) - self.tc.config(node.public_address, node.public_port, node.public_iface, \ - node.private_address, node.private_port, node.private_iface) + self.tc.config(node.public_address, + node.public_port, + node.public_iface, + node.private_address, + node.private_port, + node.private_iface) self.tc.set_upload_limit(si.upload_limit) self.tc.set_download_limit(si.download_limit) commands = self.tc.get_all_commands() - self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, commands) + #self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, commands) #sendMultipleSSHComm(node.public_address, node.username, node.ssh_port, commands) def sendSIStart(self, si): @@ -109,7 +112,11 @@ class Commander(Thread): TORRENT : torrent_file } self.printDummyCommand(node.public_address, node.listen_port, START_MSG, config_data) - self.sendComm(node.public_address, int(node.listen_port), START_MSG, config_data) + response = self.sendComm(node.public_address, + int(node.listen_port), + START_MSG, + config_data) + switch(a): def printDummyCommand(self, public_address, public_port, option1, data): print "----------------------" diff --git a/autorun/commander/XMLParser.py b/autorun/commander/XMLParser.py index 3c8f6fa..bb87da9 100644 --- a/autorun/commander/XMLParser.py +++ b/autorun/commander/XMLParser.py @@ -30,8 +30,10 @@ class Node: self.ssh_port = list[6]; self.username = list[7]; self.listen_port = list[8]; - self.clients_base_dir = list[10]; self.daemon_dir = list[9]; + self.daemon_file = list[10]; + self.clients_base_dir = list[11]; + self.clients = {}; def __str__(self): return '[%s: %s: %s: %s: %s: %s %s: %s]' \ diff --git a/autorun/xml/nodes.xml b/autorun/xml/nodes.xml index 27df668..b5e973a 100644 --- a/autorun/xml/nodes.xml +++ b/autorun/xml/nodes.xml @@ -11,6 +11,7 @@ p2p 10004 /home/p2p/cs-p2p-next/autorun/server/ + Server.py /home/p2p/p2p-clients/tribler/