start_data_tribler = {
CLIENT: TRIBLER, PORT:10150,
- BASE_DIR:"/home/p2p/p2p-clients/tribler"
+ BASE_DIR:"/home/p2p/p2p-clients/tribler",
TORRENT:"/home/p2p/p2p-meta/" + torrent_name+".torrent",
DL_DIR: "/home/p2p/p2p-dld/tribler",
LOG_DIR: "/home/p2p/p2p-log/tribler",
}
start_data_transmission = {
- CLIENT: TRANSMISSION, PORT:10150,
- BASE_DIR:"/usr/bin/"
+ CLIENT: TRANSMISSION, PORT:10250,
+ BASE_DIR:"/usr/bin/",
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", #status messages
LOG_FILE: "transmission-" + torrent_name + ".log", #verbose messages
+ }
+
+ start_data_hrktorrent = {
+ CLIENT: HRKTORRENT, PORT:10350,
+ BASE_DIR:"/home/p2p/p2p-clients/hrktorrent",
+ TORRENT: "/home/p2p/p2p-meta/" + torrent_name+".torrent",
+ DL_DIR: "/home/p2p/p2p-dld/hrktorrent",
+ LOG_DIR: "/home/p2p/p2p-log/hrktorrent",
+ OUT_FILE: torrent_name + ".out", #status messages
+ LOG_FILE: "hrktorrent-" + torrent_name + ".log", #verbose messages
+
+
}
response = s.send_command(START_MSG, start_data_tribler)
print response
def recv_pickled_data(self, clientsock):
# while chunk:
- # chunk = clientsock.recv(BUFFER_SIZE)
+ # chunk = clientsock.recv(self.BUFFER_SIZE)
# data += chunk
- data = clientsock.recv(BUFFER_SIZE)
+ data = clientsock.recv(self.BUFFER_SIZE)
dd = pickle.loads(data)
return dd
def doServer(self, ip, port):
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
if(DEBUG):
print "Server: host ip = %s, port = %d"%(SERVER_HOST,SERVER_PORT)
serversocket.bind((ip,port));
if(DEBUG):
print "Server: accepted connection from ", address
- if clientsock not in states:
- states[clientsock] = WAITING_MSG_TYPE;
+ if clientsock not in self.states:
+ self.states[clientsock] = self.WAITING_MSG_TYPE;
- if states[clientsock] == WAITING_MSG_TYPE:
- print states[clientsock]
- msg = clientsock.recv(BUFFER_SIZE)
+ if self.states[clientsock] == self.WAITING_MSG_TYPE:
+ print self.states[clientsock]
+ msg = clientsock.recv(self.BUFFER_SIZE)
if(DEBUG):
print "Server: received message:\n", msg
msg_types = {
- START_MSG: WAITING_START_DATA,
- STOP_MSG: WAITING_STOP_DATA,
- STATUS_MSG: WAITING_STATUS_DATA
+ START_MSG: self.WAITING_START_DATA,
+ STOP_MSG: self.WAITING_STOP_DATA,
+ STATUS_MSG: self.WAITING_STATUS_DATA
}
if msg not in msg_types:
clientsock.send(ERROR_MSG +"wrong message type " + msg)
else:
- states[clientsock] = msg_types[msg]
+ self.states[clientsock] = msg_types[msg]
clientsock.send(ACK_MSG)
#else:
- print states[clientsock]
+ print self.states[clientsock]
- if states[clientsock] == WAITING_START_DATA:
+ if self.states[clientsock] == self.WAITING_START_DATA:
bt_client_data = self.recv_pickled_data(clientsock)
if(DEBUG):
print "Server: received message:\n", msg
client_pid = self.start_bt_client(bt_client_data)
clientsock.send(ACK_MSG +" "+ str(client_pid))
- elif states[clientsock] == WAITING_STOP_DATA:
+ elif self.states[clientsock] == self.WAITING_STOP_DATA:
client_pid = self.recv_pickled_data(clientsock)
if(DEBUG):
print "Server: received message:\n", msg
self.stop_bt_client(client_pid)
clientsock.send(ACK_MSG)
- elif states[clientsock] == WAITING_STATUS_DATA:
+ elif self.states[clientsock] == self.WAITING_STATUS_DATA:
config = self.recv_pickled_data(clientsock)
clientsock.send(ACK_MSG)
- states[clientsock] = WAITING_MSG_TYPE
+ self.states[clientsock] = self.WAITING_MSG_TYPE
- # clientsock.recv(BUFFER_SIZE)
+ # clientsock.recv(self.BUFFER_SIZE)
# recv_pickled_data(clientsock)
clientsock.close()
# Transfers' status info is output into status_file.
FILE_NAME = "status_msg_single_download.log" #+ strftime("_%d_%b_%Y_%H_%M_%S", localtime()) + ".log"
status_file = open(FILE_NAME, 'w');
+status_file = sys.stdout
class SingleDownload:
""" This class is accessed solely by the network thread """
""" Return the local filename to which to save the file 'name' in the torrent """
if DEBUG:
print >>status_file, strftime("%d-%m-%Y %H:%M:%S", localtime())," ","SingleDownload: save_as(",`name`,length,`saveas`,isdir,")"
- status_file.close()
+ #status_file.close() # comment when status_file is stdout
try:
if not os.access(saveas,os.F_OK):
os.mkdir(saveas)