]> p2p-next.cs.pub.ro Git - cs-p2p-next.git/commitdiff
server - minor changes
authorAdriana Draghici <adriana008@gmail.com>
Fri, 5 Mar 2010 13:47:19 +0000 (15:47 +0200)
committerAdriana Draghici <adriana008@gmail.com>
Fri, 5 Mar 2010 13:47:19 +0000 (15:47 +0200)
bt_comm/server/Client.py
bt_comm/server/Server_NO_DAEMON.py
bt_comm/start-clients/BitTorrentClientRun.py
bt_comm/start-clients/TransmissionRun.py

index ebdc9c7337728b9b42e1483cdb1652eb1d0de5fe..cb5cfe39db9e1467de13dd9daa31b7e0fa7ea84e 100644 (file)
@@ -52,11 +52,11 @@ def test_all_commands():
     s = MySocket()
     s.connect(SERVER_HOST, SERVER_PORT)
     start_data = {CLIENT: TRANSMISSION, PORT:10150, 
-            TORRENT: "/home/adriana/p2p/p2p-meta/scrubs.torrent",
+            TORRENT: "/home/adriana/p2p/p2p-meta/photos.zip.torrent",
             DL_DIR: "/home/adriana/p2p/p2p-dld/transmission",
             LOG_DIR: "/home/adriana/p2p/p2p-log/transmission",
-            OUT_FILE: "scrubs.out",
-            LOG_FILE: "transmission-scrubs.log",
+            OUT_FILE: "photos.zip.out",
+            LOG_FILE: "transmission-photos.zip.log",
 
             }
     response = s.send_command(START_MSG, start_data)
@@ -65,7 +65,7 @@ def test_all_commands():
     print pid
     s = MySocket()
     s.connect(SERVER_HOST, SERVER_PORT)
-    time.sleep(30)
+    time.sleep(60)
     response = s.send_command(STOP_MSG, pid)
     print response
 
index 5da2405cd7d550ee1361f507d83bf5892fe46464..da051d4b55e7d22b2d218070d380aa262adca6f3 100644 (file)
@@ -11,7 +11,7 @@ from TransmissionRun import *
 BUFFER_SIZE = 4096
 
 states = {} # keeps track of what kind of message was previously receveid on a socket.
-
+processes = {}
 WAITING_MSG_TYPE = 0
 WAITING_START_DATA = 3
 WAITING_STOP_DATA = 4
@@ -39,7 +39,9 @@ def start_bt_client(bt_client_data):
             bt_client_data[TORRENT])
 
         btcr.start()
-        pid = btcr.run_client(btcr.simple_run_command)
+        [pid, log_fd, output_fd] = btcr.run_client(btcr.simple_run_command)
+        processes[pid] = (log_fd, output_fd)
+        print processes[pid]
         if(DEBUG):
             print "Server: started client with pid = ", pid
         return pid
@@ -60,8 +62,14 @@ def start_bt_client(bt_client_data):
 
 def stop_bt_client(pid):
     
-    os.kill(int(pid), signal.SIGKILL) # kill generates zombies
-    os.wait() 
+    int_pid = int(pid)
+    os.kill(int_pid, signal.SIGKILL) # kill generates zombies
+    os.wait()
+    print int_pid
+    print processes 
+    processes[int_pid][0].close() 
+    processes[int_pid][1].close()
+    del processes[int_pid] 
     if(DEBUG):
         print "Server: killed process with pid = ", pid
 
index 83311c0dc081bf9cf1414a91f186fdfcdf4cf89e..a5be85f41fc31080f847106c891a3368f2224ceb 100644 (file)
@@ -72,7 +72,7 @@ class BitTorrentClientRun:
         pid = p.pid
         if(DEBUG):
             print "BitTorrentClientRun: pid =", pid
-        return pid
+        return [pid, log_redirect, output_redirect]
         
 
 def main():
index 2a6917d3542a6b99a6c8f67d7c60cfdc1a80853b..1f100bca045407b425c0aa921cdcf0e07a33b63b 100644 (file)
@@ -15,13 +15,9 @@ DEBUG = False
 class TransmissionRun(BitTorrentClientRun):
     def __init__(self, base_path):
         BitTorrentClientRun.__init__(self, base_path,
-                "$base_path  --port $port $torrent_file $download_dir> $output_dir/$output_file",
-                "TR_DEBUG=2 $base_path  --port $port $torrent_file $download_dir 2> $log_dir/$log_file > $output_dir/$output_file")
-        # for some versions of transmission the cmdline arguments are given differently:
-        """BitTorrentClientRun.__init__(self, base_path,
                 "$base_path --download-dir $download_dir --port $port $torrent_file > $output_dir/$output_file", 
                 "TR_DEBUG=2 $base_path --download-dir $download_dir --port $port $torrent_file 2> $log_dir/$log_file > $output_dir/$output_file")
-        """
+        
 
 def main():