if DEBUG == True:
print "[verbose_messages] insert row", row
try:
- self.cursor.execute("insert into verbose_messages values (?,?,?,?,?,?,?,?,?)", row)
+ self.cursor.execute("insert into verbose_messages values (?,?,?,?,?,?,?,?,?,?)", row)
self.conn.commit()
except sqlite3.Error, e:
print ("[verbose_messages]An error ocurred: ", e.args[0])
- def insert_verbose_messages(self, cs_id, timestamp, peer_ip, peer_port, message_type, _index, begin, length, listen_port):
- self.insert_verbose_messages_row([cs_id, timestamp, peer_ip, peer_port, message_type, _index, begin, length, listen_port])
+ def insert_verbose_messages(self, cs_id, timestamp, direction, peer_ip, peer_port, message_type, _index, begin, length, listen_port):
+ self.insert_verbose_messages_row([cs_id, timestamp, direction, peer_ip, peer_port, message_type, _index, begin, length, listen_port])
def select_verbose_messages(self, show = True, cs_id = -1, restrictArray=None):
try:
Test case
"""
- dba = DatabaseAccess("p2p-next.db")
+ if len(sys.argv) != 2:
+ print "Usage: python DatabaseAccess dbfile"
+ sys.exit(2)
+
+ dba = DatabaseAccess(sys.argv[1])
dba.connect()
]:
dba.insert_status_messages_row(t)
- for t in [('1', '2455128.121295811', '127.0.0.1', '1345', '0', '3', '4', '13', '777'),
- ('4', '2455128.121295811', '127.0.0.1', '1345', '0', '3', '4', '13', '777'),
+ for t in [('1', '2455128.121295811', '0', '127.0.0.1', '1345', '0', '3', '4', '13', '777'),
+ ('4', '2455128.121295811', '1', '127.0.0.1', '1345', '0', '3', '4', '13', '777'),
]:
dba.insert_verbose_messages_row(t)
self.dba = DatabaseAccess(dbname)
self.dba.connect()
- def add_status_message(self, cs_id, date, time, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta_time):
+ def add_status_message(self, cs_id, date, time, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds):
timestamp = float(julian.stringToJulian(date, time));
- eta = datetime.timedelta(eta_time[0], eta_time[3], 0, 0, eta_time[2], eta_time[1], 0)
- eta_seconds = eta.days * 24 * 3600 + eta.seconds
self.dba.insert_status_messages(cs_id, timestamp, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds)
- def add_status_message_datetime(self, cs_id, dt, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta_time):
+ def add_status_message_datetime(self, cs_id, dt, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds):
timestamp = float(julian.datetimeToJulian(dt));
- # adriana >:)
- #eta = datetime.timedelta(eta_time[0], eta_time[3], 0, 0, eta_time[2], eta_time[1], 0)
- #eta_seconds = eta.days * 24 * 3600 + eta.seconds
- eta_seconds = eta_time #!!! already in seconds (tribler's fault) !!!!
self.dba.insert_status_messages(cs_id, timestamp, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta_seconds)
- def add_verbose_message(self, cs_id, date, time, peer_ip, peer_port, message_type, index, begin, length, listen_port):
+ def add_verbose_message(self, cs_id, date, time, direction, peer_ip, peer_port, message_type, index, begin, length, listen_port):
timestamp = float(julian.stringToJulian(date, time));
- self.dba.insert_verbose_messages(cs_id, timestamp, peer_ip, peer_port, message_type, index, begin, length, listen_port)
+ self.dba.insert_verbose_messages(cs_id, timestamp, direction, peer_ip, peer_port, message_type, index, begin, length, listen_port)
- def add_verbose_message(self, cs_id, dt, peer_ip, peer_port, message_type, index, begin, length, listen_port):
+ def add_verbose_message_datetime(self, cs_id, dt, direction, peer_ip, peer_port, message_type, index, begin, length, listen_port):
timestamp = float(julian.datetimeToJulian(dt));
- self.dba.insert_verbose_messages(cs_id, timestamp, peer_ip, peer_port, message_type, index, begin, length, listen_port)
+
+ self.dba.insert_verbose_messages(cs_id, timestamp, direction, peer_ip, peer_port, message_type, index, begin, length, listen_port)
def show_status_messages(self, cs_id = -1):
self.dba.select_status_messages(True, cs_id)