updated status parser to use seconds for ETA when calling add_status_messages_datetim...
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 21 Nov 2009 19:10:08 +0000 (21:10 +0200)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 21 Nov 2009 19:11:39 +0000 (21:11 +0200)
log-parser/libtorrent/StatusParser.py

index 30f1f29..bfc8649 100644 (file)
@@ -60,11 +60,8 @@ def libtorrent_canon_eta(non_canon_value):
     for i in range(len(eta_string_array), 4):
         eta.insert(0, 0)
     
-    # adriana >:)
-    eta2 = datetime.timedelta(eta[0], eta[3], 0, 0, eta[2], eta[1], 0)
-    eta_seconds = eta.days * 24 * 3600 + eta.seconds
-    return eta_seconds
-    #return eta
+    eta_td = datetime.timedelta(eta[0], eta[3], 0, 0, eta[2], eta[1], 0)
+    return eta_td
 
 #
 # sample libtorrent status line
@@ -102,8 +99,9 @@ def libtorrent_parse_status_line(line):
             pass
         if pair[0] == "eta":
             eta = libtorrent_canon_eta(pair[1])
+            eta_seconds = eta.days * 24 * 3600 + eta.seconds
 
-    return (num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta)
+    return (num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds)
 
 def libtorrent_parse_status_file(dbw, client_session_id, session_start, filename):
 
@@ -121,14 +119,14 @@ def libtorrent_parse_status_file(dbw, client_session_id, session_start, filename
             if libtorrent_is_status_line(line) == False:
                 continue
 
-            (num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta_time) = libtorrent_parse_status_line(line)
+            (num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds) = libtorrent_parse_status_line(line)
 
             message_time = message_time + one_second
 
             if DEBUG == True:
                 print "(%d, %s, %s, %d, %d kb/s, %d kb/s, %d bytes, %d bytes)" % (num_peers, date, time, dht, download_speed, upload_speed, download_size, upload_size)
             
-            dbw.add_status_message_datetime(client_session_id, message_time, num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta_time)
+            dbw.add_status_message_datetime(client_session_id, message_time, num_peers, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds)
 
     except IOError:
         print "Error processing file %s." %filename