From: Adriana Draghici Date: Fri, 12 Mar 2010 15:31:18 +0000 (+0000) Subject: bt_comm - start and stop Tribler X-Git-Tag: getopt_long~139 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=acac6bf5807f282fa90b1e61bddf5aa73cd14812;p=cs-p2p-next.git bt_comm - start and stop Tribler --- diff --git a/bt_comm/server/Client.py b/bt_comm/server/Client.py index 1783458..41f6266 100644 --- a/bt_comm/server/Client.py +++ b/bt_comm/server/Client.py @@ -58,8 +58,8 @@ def test_all_commands(torrent_file): TORRENT:"/home/p2p/p2p-meta/" + torrent_name+".torrent", DL_DIR: "/home/p2p/p2p-dld/tribler", LOG_DIR: "/home/p2p/p2p-log/tribler", - OUT_FILE: torrent_name + ".out", - LOG_FILE: "tribler-" + torrent_name + ".log", + OUT_FILE: torrent_name + ".out", #status messages + LOG_FILE: "tribler-" + torrent_name + ".log", #verbose messages } start_data_transmission = { @@ -67,8 +67,8 @@ def test_all_commands(torrent_file): TORRENT: "/home/p2p/p2p-meta/" + torrent_name+".torrent", 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", + OUT_FILE: torrent_name + ".out", #status messages + LOG_FILE: "transmission-" + torrent_name + ".log", #verbose messages } response = s.send_command(START_MSG, start_data_tribler) @@ -77,7 +77,7 @@ def test_all_commands(torrent_file): print pid s = MySocket() s.connect(SERVER_HOST, SERVER_PORT) - time.sleep(160) + time.sleep(100) response = s.send_command(STOP_MSG, pid) print response diff --git a/bt_comm/start-clients/BitTorrentClientRun.py b/bt_comm/start-clients/BitTorrentClientRun.py index 3d70e0e..c2b7141 100644 --- a/bt_comm/start-clients/BitTorrentClientRun.py +++ b/bt_comm/start-clients/BitTorrentClientRun.py @@ -61,8 +61,6 @@ class BitTorrentClientRun: # split command args = shlex.split(command) - if(DEBUG): - print "BitTorrentClientRun: command =", args # remove redirectation parameters for i in range(0, len(args)): @@ -70,8 +68,10 @@ class BitTorrentClientRun: for j in range(i, len(args)): args.pop(i) break; - - + if(DEBUG): + print "BitTorrentClientRun: command =", args + os.system("PYTHONPATH=/home/p2p/p2p-clients/tribler"); + args.pop(0) log_redirect = open(self.log_dir+"/"+self.log_file,"w") output_redirect = open(self.output_dir+"/"+self.output_file,"w") p=subprocess.Popen(args, shell=False, #does not create sh process diff --git a/bt_comm/start-clients/TriblerRun.py b/bt_comm/start-clients/TriblerRun.py index 2a9c8dc..9834c9a 100644 --- a/bt_comm/start-clients/TriblerRun.py +++ b/bt_comm/start-clients/TriblerRun.py @@ -14,10 +14,42 @@ DEBUG = False class TriblerRun(BitTorrentClientRun): def __init__(self, base_path): + + self.set_PYTHONPATH(base_path) BitTorrentClientRun.__init__(self, base_path, "PYTHONPATH=$base_path python $base_path/Tribler/Tools/cmdlinedl.py -o $download_dir -p $port $torrent_file 2> $log_dir/$log_file > $output_dir/$output_file", "PYTHONPATH=$base_path python $base_path/Tribler/Tools/cmdlinedl.py -o $download_dir -p $port $torrent_file 2> $log_dir/$log_file > $output_dir/$output_file") + + """ + Adds lines in cmdlinedl.py that set the PYTHONPATH variable. + """ + def set_PYTHONPATH(self, base_path): + filename = base_path + "/Tribler/Tools/cmdlinedl.py" + tmp_filename = filename + "_tmp" + if not os.path.exists(filename) or not os.path.isfile(filename): + print "Error: invalid Tribler path ", filename + return + f = open(filename, "r"); + f_copy = open(tmp_filename, "w"); + import_line = "import sys" + instr_line = "\nsys.path.append('"+base_path+"')\n" + exists = False + position = -1 + for line in f: + if line.find("import")>=0 and line.find("sys")>=0 and (not line.find("sys."))>=0: + #position = f.tell() + len(line) + 1 + f_copy.write(line) + f_copy.write(instr_line) + continue + if line == instr_line: + continue + f_copy.write(line) + + f_copy.close() + os.remove(filename) + os.rename(tmp_filename, filename) + f.close() def main(): @@ -26,8 +58,8 @@ def main(): """ tr = TriblerRun("/home/p2p/p2p-clients/tribler") - tr.config_run("/home/p2p/p2p-dld/tribler", "/home/p2p/p2p-log/tribler", "tribler-fedora.out", "/home/p2p/p2p-log/tribler", "tribler-fedora.log", 10150, "/home/p2p/p2p-meta/fedora.torrent") - tr.start() + #tr.config_run("/home/p2p/p2p-dld/tribler", "/home/p2p/p2p-log/tribler", "tribler-fedora.out", "/home/p2p/p2p-log/tribler", "tribler-fedora.log", 10150, "/home/p2p/p2p-meta/fedora.torrent") + #tr.start() if __name__ == "__main__":