X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=blobdiff_plain;f=apt_p2p%2Fstats.py;h=06e291bd154a21b4e797713b3082b4829821262f;hp=640c57f373a3170c7a2666c92542e81e58990906;hb=a9f0deccc4673d5332622ce40407ff009af6c8a3;hpb=24845555abc95ac759420d1ca8c67c5eb5512fc2 diff --git a/apt_p2p/stats.py b/apt_p2p/stats.py index 640c57f..06e291b 100644 --- a/apt_p2p/stats.py +++ b/apt_p2p/stats.py @@ -4,7 +4,7 @@ from datetime import datetime, timedelta from StringIO import StringIO -from util import byte_format +from util import uncompact, byte_format class StatsLogger: """Store the statistics for the Khashmir DHT. @@ -39,8 +39,7 @@ class StatsLogger: """ # Database self.db = db - self.lastDBUpdate = datetime.now() - self.hashes, self.files = self.db.dbStats() + self.hashes, self.files = 0, 0 # Transport self.mirrorDown = 0L @@ -61,17 +60,6 @@ class StatsLogger: } self.db.saveStats(stats) - def dbStats(self): - """Collect some statistics about the database. - - @rtype: (C{int}, C{int}) - @return: the number of keys and values in the database - """ - if datetime.now() - self.lastDBUpdate > timedelta(minutes = 1): - self.lastDBUpdate = datetime.now() - self.hashes, self.files = self.db.keyStats() - return (self.hashes, self.files) - def formatHTML(self, contactAddress): """Gather statistics for the DHT and format them for display in a browser. @@ -79,7 +67,7 @@ class StatsLogger: @rtype: C{string} @return: the stats, formatted for display in the body of an HTML page """ - self.dbStats() + self.hashes, self.files = self.db.dbStats() out = StringIO() out.write('
General | Value |
---|---|
Contact | " + str(contactAdress) + ' |
Contact | " + str(uncompact(contactAddress)) + ' |