From: Adriana Draghici Date: Fri, 5 Mar 2010 13:47:19 +0000 (+0200) Subject: server - minor changes X-Git-Tag: getopt_long~144 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=73c60ff17031b8d9fcecbc03e1d91a8194cfc298;p=cs-p2p-next.git server - minor changes --- diff --git a/bt_comm/server/Client.py b/bt_comm/server/Client.py index ebdc9c7..cb5cfe3 100644 --- a/bt_comm/server/Client.py +++ b/bt_comm/server/Client.py @@ -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 diff --git a/bt_comm/server/Server_NO_DAEMON.py b/bt_comm/server/Server_NO_DAEMON.py index 5da2405..da051d4 100644 --- a/bt_comm/server/Server_NO_DAEMON.py +++ b/bt_comm/server/Server_NO_DAEMON.py @@ -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 diff --git a/bt_comm/start-clients/BitTorrentClientRun.py b/bt_comm/start-clients/BitTorrentClientRun.py index 83311c0..a5be85f 100644 --- a/bt_comm/start-clients/BitTorrentClientRun.py +++ b/bt_comm/start-clients/BitTorrentClientRun.py @@ -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(): diff --git a/bt_comm/start-clients/TransmissionRun.py b/bt_comm/start-clients/TransmissionRun.py index 2a6917d..1f100bc 100644 --- a/bt_comm/start-clients/TransmissionRun.py +++ b/bt_comm/start-clients/TransmissionRun.py @@ -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():