server: minor changes.
authorAdriana Draghici <adriana008@gmail.com>
Thu, 11 Mar 2010 12:50:58 +0000 (12:50 +0000)
committerAdriana Draghici <adriana008@gmail.com>
Thu, 11 Mar 2010 12:50:58 +0000 (12:50 +0000)
bt_comm/README
bt_comm/server/Client.py

index b2fd846..9ba7e85 100644 (file)
@@ -1,6 +1,7 @@
 server/Server.py - serverul ce ruleaza ca daemon
 server/Server_NO_DAEMON.py - folosit pt testarea functionarii, nu este daemon
 server/Client.py - testeaza comunicatia cu serverul folosind sockets
+                - usage: python Client.py torrent_file
 Util.py - constante folosite atat de server cat si de commander
 start-clients/BitTorrentClientRun - porneste instante de clienti bittorrent
 start-clients/*Run.py - subclase ale BitTorrentClientRun modificate pt fiecare client in parte.
index cb5cfe3..3eccafb 100644 (file)
@@ -48,15 +48,16 @@ class MySocket:
         self.send_msg(dumped_data)
 
 # basic test that starts and stops a BT Client
-def test_all_commands():
+def test_all_commands(torrent_file):
     s = MySocket()
     s.connect(SERVER_HOST, SERVER_PORT)
+    torrent_name = torrent_file[(torrent_file.rfind("/")+1):torrent_file.find(".torrent")];
     start_data = {CLIENT: TRANSMISSION, PORT:10150, 
-            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: "photos.zip.out",
-            LOG_FILE: "transmission-photos.zip.log",
+            TORRENT: "/home/p2p/p2p-meta/" + torrent_file,
+            DL_DIR: "/home/p2p/p2p-dld/transmission",
+            LOG_DIR: "/home/p2p/p2p-log/transmission",
+            OUT_FILE: torrent_name + ".out",
+            LOG_FILE: "transmission-" + torrent_name + ".log",
 
             }
     response = s.send_command(START_MSG, start_data)
@@ -65,7 +66,7 @@ def test_all_commands():
     print pid
     s = MySocket()
     s.connect(SERVER_HOST, SERVER_PORT)
-    time.sleep(60)
+    time.sleep(160)
     response = s.send_command(STOP_MSG, pid)
     print response
 
@@ -81,5 +82,7 @@ def test_send_recv():
 
 if __name__ == "__main__":
 
-    
-    test_all_commands()
+    if len(sys.argv) != 2:
+        print "Usage: python %s <torrent_file>"%sys.argv[0]
+    else:
+        test_all_commands(sys.argv[1])