updated Util with SERVER globals
authorMarius Sandu-Popa <sandupopamarius@gmail.com>
Thu, 15 Apr 2010 11:15:48 +0000 (14:15 +0300)
committerMarius Sandu-Popa <sandupopamarius@gmail.com>
Thu, 15 Apr 2010 11:15:48 +0000 (14:15 +0300)
autorun/Util.py
autorun/commander/Commander.py
autorun/commander/XMLParser.py
autorun/xml/nodes.xml

index 10a4128..9624d81 100644 (file)
@@ -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"
index 83effec..a1b4a4f 100644 (file)
@@ -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 "----------------------"
index 3c8f6fa..bb87da9 100644 (file)
@@ -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]' \
index 27df668..b5e973a 100644 (file)
@@ -11,6 +11,7 @@
        <username>p2p</username>
        <listen_port>10004</listen_port>
        <daemon_dir>/home/p2p/cs-p2p-next/autorun/server/</daemon_dir>
+       <daemon_file>Server.py</daemon_file>
        <clients>
            <client id="tribler">
                <base>/home/p2p/p2p-clients/tribler/</base>