Skip to content

Commit

Permalink
Fixed stats crawler (run on raw server)
Browse files Browse the repository at this point in the history
  • Loading branch information
Devristo committed Dec 16, 2013
1 parent 4559109 commit ba1632c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Tribler/community/anontunnel/StatsCrawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def init_sql():
self.raw_server.add_task(init_sql)

def on_tunnel_stats(self, community, candidate, stats):
self.raw_server.add_task(lambda: self.on_stats(community, candidate, stats))

def on_stats(self, community, candidate, stats):
sock_address = candidate.sock_addr
cursor = self.conn.cursor()

try:

cursor.execute('''INSERT OR FAIL INTO result
(session_id, time, host, port, swift_size, swift_time, bytes_enter, bytes_exit, bytes_returned)
VALUES (?,DATETIME('now'),?,?,?,?,?,?,?)''',
Expand Down Expand Up @@ -98,7 +100,7 @@ def on_tunnel_stats(self, community, candidate, stats):

logger.warning("Storing stats data off %s:%d" % sock_address)
except sqlite3.IntegrityError:
logger.info("Already stored this stat")
logger.error("Already stored this stat")
except BaseException as e:
logger.exception(e)

Expand Down
6 changes: 3 additions & 3 deletions Tribler/community/anontunnel/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class ProxySettings:
def __init__(self):
length = randint(1, 4)
length = 1#randint(1, 4)

self.extend_strategy = ExtendStrategies.TrustThyNeighbour
self.select_strategy = RandomSelectionStrategy(1)
Expand All @@ -47,7 +47,7 @@ def on_state_change(self, community, state):
def on_tunnel_data(self, community, origin, data):
pass

def on_stats(self, community, candidate, stats):
def on_tunnel_stats(self, community, candidate, stats):
pass

class Circuit:
Expand Down Expand Up @@ -299,7 +299,7 @@ def on_introduction_response(self, messages):
def on_stats(self, messages):
for message in messages:
for o in self.__observers:
o.on_stats(self, message.candidate, message.payload.stats)
o.on_tunnel_stats(self, message.candidate, message.payload.stats)

def send_stats(self, stats):
meta = self.get_meta_message(u"stats")
Expand Down

0 comments on commit ba1632c

Please sign in to comment.