SERVER_TYPE = "python"
SERVER_PORT = 10004
SERVER_HOST = "172.16.20.3"
+
import os
def get_sessions_file_path():
dirpath = os.environ['HOME']+"/"+".autorun/"
NUM_PEERS = "num_peers"
-import os.path
-import time
-def create_archive_file(file_path):
- try:
- print "Archive file: ", file_path
-
- if os.path.isfile(file_path):
- # archive file
- archive_name = file_path + time.strftime("%d%m%Y_%H%M%S", time.localtime()) + ".zip"
- command = "zip " + archive_name + " " + file_path
- print command
- os.system(command)
- # remove file
- command = "rm " + file_path
- os.system(command)
- return 0
- return -1
- except Exception,ex:
- raise
-
-
-def create_archive_dir_logs(dir_path):
- try:
- if not os.path.isfile(dir_path):
- # archive all log files
- archive_name = dir_path + "/" + "hrk_" + time.strftime("%d%m%Y_%H%M%S", time.localtime()) + ".zip"
- command = "zip "+ archive_name + " " + dir_path + "/libtorrent*" + " " + dir_path + "/*log"
- print command
- os.system(command)
-
- # remove log files
- command = "rm " + dir_path + "libtorrent *" + " " + dir_path + "/*log"
- os.system(command)
- return 0
- return -1
- except Exception,ex:
- raise
print self.simple_run_command
print self.logging_run_command
- def run_client(self, command):
+ def run_client(self, command, client):
try:
# split command
args = shlex.split(command)
output_redirect = open(self.output_dir+"/"+self.output_file,"w")
self.my_logger.debug(" output redirect to file " + self.output_dir+"/"+self.output_file)
log_redirect = None
- if self.log_file != "":
+ if client != HRKTORRENT:
log_redirect = open(self.log_dir+"/"+self.log_file,"w")
self.my_logger.debug(" log redirect to file " + self.log_dir+"/"+self.log_file)
else: #for HRKTORRENT
try:
f = open(SESSIONS_FILE, 'a')
#f.write ("# session " + strftime("%d-%m-%Y %H:%M:%S", localtime())+ "\n")
-
num_lines = len(data.keys())
if PORT in data:
num_lines = num_lines -1;
self.logger(" Exception while saving transfer info: " + str(ex))
raise
+
+ def create_archive_file(file_path):
+ try:
+ print "Archive file: ", file_path
+
+ if os.path.isfile(file_path):
+ # archive file
+ archive_name = file_path + time.strftime("%d%m%Y_%H%M%S", time.localtime()) + ".zip"
+ command = "zip " + archive_name + " " + file_path
+ print command
+ os.system(command)
+ # remove file
+ command = "rm " + file_path
+ os.system(command)
+ return 0
+ return -1
+ except Exception,ex:
+ raise
+
+
+ def create_archive_dir_logs(dir_path):
+ try:
+ if not os.path.isfile(dir_path):
+ # archive all log files
+ archive_name = dir_path + "/" + "hrk_" + time.strftime("%d%m%Y_%H%M%S", time.localtime()) + ".zip"
+ command = "zip "+ archive_name + " " + dir_path + "/libtorrent*" + " " + dir_path + "/*log"
+ print command
+ os.system(command)
+
+ # remove log files
+ command = "rm " + dir_path + "/libtorrent*" + " " + dir_path + "/*log"
+ os.system(command)
+ return 0
+ return -1
+ except Exception,ex:
+ raise
+
def add_to_output_msg(self, file_list, info_dict):
""" Constructs a list with self.logger file info - paths, client, metafile
@param file_list list to which the created self.logger info list in appended. """
-
+
if CLIENT not in info_dict and TORRENT not in info_dict:
return -1
info_list = [info_dict[CLIENT],info_dict[TORRENT]]
bt_client_data[TORRENT])
btcr.start()
- [pid, log_fd, output_fd] = btcr.run_client(btcr.simple_run_command)
+ [pid, log_fd, output_fd] = btcr.run_client(btcr.simple_run_command, bt_client_data[CLIENT])
self.processes_fd[pid] = [log_fd, output_fd]
self.processes_info[pid] = [bt_client_data[CLIENT],
bt_client_data[TORRENT],