download_speed, upload_speed,
download_size, upload_size,
eta_seconds):
- print "time = %s, ps = %d, dht = %d, ds = %d kb/s, us = %d kb/s, dsize = %d bytes, usize = %d bytes" % (timestamp.strftime("%H:%M:%S %d/%m/%y"), num_peers, dht, download_speed, upload_speed, download_size, upload_size)
+ print "time = %s, ps = %d, dht = %d, ds = %d kb/s, us = %d kb/s, dsize = %d bytes, usize = %d bytes" % (timestamp.strftime("%H:%M:%S %d-%m-%y"),
+ num_peers, dht, download_speed, upload_speed, download_size, upload_size)
def parse(self, callback_func, callback_arg = None):
try:
#
def canon_dht(self, non_canon_value):
return int(non_canon_value)
+
+ # return datetime object
+ #
+ def canon_datetime(self, non_canon_value):
+ string_parts = re.split("\ *", non_canon_value)
+ if len(string_parts) != 2:
+ return None
+ date_array = string_parts[0].split("-");
+ time_array = string_parts[1].split(":");
+ if len(date_array) != 3 or len(time_array) != 3:
+ return None
+ timestamp = datetime.datetime(int(date_array[2]), int(date_array[1]), int(date_array[0]), #year, month, day
+ int(time_array[0]), int(time_array[1]), int(time_array[2])) #hour, min, sec
+ return timestamp
# return integer
#
logging.debug("string_array is %s" % string_array)
for string in string_array:
- pair = re.split("\ *:\ *", string)
+ pair = re.split("\ *:\ +", string)
if pair[0] == "ps":
num_peers = self.canon_num_peers(pair[1])
if pair[0] == "dht":
dht = self.canon_dht(pair[1])
+ if pair[0] == "time":
+ datetime = self.canon_datetime(pair[1])
if pair[0] == "dl":
download_speed = self.canon_download_speed(pair[1])
if pair[0] == "ul":
eta_seconds = self.timedelta_to_seconds(self.canon_eta(pair[1]))
self.timestamp += ONE_SECOND
-
+ self.timestamp = datetime
return (self.timestamp, num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds)