4. Mesaje STATUS
- trimise de client pt interogarea starii
- -----> tipul mesajului STATUS_MSG (definit in Util.py)
- ----->
-
+ -----> (tipul mesajului STATUS_MSG, identificator transfer )
+ <----- tuplu (ACK, dictionar cu parametrii transferului )
+ - identificatorul unui transfer reprezinta pid-ul intors de server la
+ pornirea unui client pt un anumit fisier
+ - parametrii transferului pot fi:
+ - timestamp
+ - nume fisier torrent
+ - upload, download speed
+ - upload, download size
+ - eta
+ - number of peers
START_MSG = 1
STOP_MSG = 2
-STATUS_MSG = 3
+GET_STATUS = 3
GET_CLIENTS = 4
GET_OUTPUT = 5
ARCHIVE = 6
else: # erase sessions file
f = open(SESSIONS_FILE, "w")
f.close()
+
+ elif msg[0] == GET_STATUS:
+ #TODO: current ideea: call parse_status_line from GenericStatusParser
+ # create a dictionary from the returned list, its better to use a dictionary
+ # because it is position independent
+ pass
+
else:
err_msg = "Error: wrong message type";
return (num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta)
+ def parse_last_status_line(self, filename,line):
+ # read last line from status log file
+ f = open(filename, "r")
+ f.seek(-1, os.SEEK_END)
+
+ # seek before the beginning of the last line
+
+ while f.read(1) != '\n' :
+ f.seek(-2, os.SEEK_CUR)
+ line = f.readline()
+ f.close()
+ return self.parse_status_line(line)
+
def parse_status_file(self, client_session_id, session_start, filename, callback_func, callback_arg = None):
message_time = session_start