From: Adriana Draghici Date: Thu, 11 Mar 2010 12:50:58 +0000 (+0000) Subject: server: minor changes. X-Git-Tag: getopt_long~142 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=b0e51197c50c35b9fa8da1d21a94e3abd986befa;p=cs-p2p-next.git server: minor changes. --- diff --git a/bt_comm/README b/bt_comm/README index b2fd846..9ba7e85 100644 --- a/bt_comm/README +++ b/bt_comm/README @@ -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. diff --git a/bt_comm/server/Client.py b/bt_comm/server/Client.py index cb5cfe3..3eccafb 100644 --- a/bt_comm/server/Client.py +++ b/bt_comm/server/Client.py @@ -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 "%sys.argv[0] + else: + test_all_commands(sys.argv[1])