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.
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)
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
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])