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 = {
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)
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
# split command
args = shlex.split(command)
- if(DEBUG):
- print "BitTorrentClientRun: command =", args
# remove redirectation parameters
for i in range(0, len(args)):
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
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():
"""
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__":