r411 - /debtorrent/trunk/DebTorrent/BT1/track.py
camrdale-guest at users.alioth.debian.org
camrdale-guest at users.alioth.debian.org
Sun Jan 11 05:22:45 UTC 2009
Author: camrdale-guest
Date: Sun Jan 11 05:22:45 2009
New Revision: 411
URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=411
Log:
Save all-time tracker statistics even after torrents are removed.
Modified:
debtorrent/trunk/DebTorrent/BT1/track.py
Modified: debtorrent/trunk/DebTorrent/BT1/track.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/track.py?rev=411&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/track.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/track.py Sun Jan 11 05:22:45 2009
@@ -740,26 +740,27 @@
else:
names = [ (None,hash) for hash in self.downloads.keys() ]
+ total_uploaded = 0L
+ total_downloaded = 0L
+
+ # Write the table headers
+ s.write('<table summary="files" border="1">\n\n' \
+ '<tr><th>torrent name/<br><code> info hash</code></th>\n')
+ if self.config['allowed_dir']:
+ s.write('<th align="right">size</th>\n')
+ s.write('<th align="right">peers</th>\n' \
+ '<th align="right">downloaded</th>\n' \
+ '<th align="right">uploaded</th>\n' \
+ '<th align="right">saved</th></tr>\n\n')
+
if not names:
- s.write('<p>not tracking any files yet...</p>\n')
+ s.write('<tr><td>not tracking any files yet...</td></tr>\n')
else:
names.sort()
number_files = 0
total_peers = 0
- total_uploaded = 0L
- total_downloaded = 0L
total_size = 0L
- # Write the table headers
- s.write('<table summary="files" border="1">\n\n' \
- '<tr><th>torrent name/<br><code> info hash</code></th>\n')
- if self.config['allowed_dir']:
- s.write('<th align="right">size</th>\n')
- s.write('<th align="right">peers</th>\n' \
- '<th align="right">downloaded</th>\n' \
- '<th align="right">uploaded</th>\n' \
- '<th align="right">saved</th></tr>\n\n')
-
# Display a table row for each torrent
for name,hash in names:
# Get the stats for this torrent
@@ -818,16 +819,32 @@
% (total_peers, size_format(total_downloaded),
size_format(total_uploaded), saved))
- # Write a rudimentary legend
- s.write('</table>\n' \
- '<ul>\n' \
- '<li><em>torrent name:</em> possible names for the torrent</li>\n' \
- '<li><em>info hash:</em> torrent identifier</li>\n' \
- '<li><em>peers:</em> number of connected clients</li>\n' \
- '<li><em>downloaded:</em> amount of data downloaded by all peers, this data may have been downloaded from a mirror or another peer</li>\n' \
- '<li><em>uploaded:</em> amount of data uploaded by all peers, this is the amount of bandwidth that was saved from the mirrors</li>\n' \
- '<li><em>saved:</em> percentage of data that was NOT downloaded from a mirror</li>\n' \
- '</ul>\n')
+ # Another table footer with all-time statistics
+ total_downloaded += self.stats['global']['downloaded']
+ total_uploaded += self.stats['global']['uploaded']
+ saved = 0.0
+ if total_downloaded > 0:
+ saved = 100.0 * float(total_uploaded) / float(total_downloaded)
+ s.write('<tr><td align="right">All-time totals</td>\n')
+ if self.config['allowed_dir']:
+ s.write('<td></td>\n')
+ s.write('<td></td>\n' \
+ '<td align="right">%s</td>\n' \
+ '<td align="right">%s</td>\n' \
+ '<td align="right">%0.1f %%</td></tr>\n\n'
+ % (size_format(total_downloaded),
+ size_format(total_uploaded), saved))
+
+ # Write a rudimentary legend
+ s.write('</table>\n' \
+ '<ul>\n' \
+ '<li><em>torrent name:</em> possible names for the torrent</li>\n' \
+ '<li><em>info hash:</em> torrent identifier</li>\n' \
+ '<li><em>peers:</em> number of connected clients</li>\n' \
+ '<li><em>downloaded:</em> amount of data downloaded by all peers, this data may have been downloaded from a mirror or another peer</li>\n' \
+ '<li><em>uploaded:</em> amount of data uploaded by all peers, this is the amount of bandwidth that was saved from the mirrors</li>\n' \
+ '<li><em>saved:</em> percentage of data that was NOT downloaded from a mirror</li>\n' \
+ '</ul>\n')
s.write('</body>\n' \
'</html>\n')
@@ -1627,6 +1644,9 @@
self.allowed is None or not self.allowed.has_key(key) ) and (
self.keep_dead != 1 or (self.stats.get(key, {}).get('uploaded', 0) <= 0 and
self.stats.get(key, {}).get('downloaded', 0) <= 0)):
+ self.stats['global']['downloaded'] += self.stats.get(key, {}).get('downloaded', 0)
+ self.stats['global']['uploaded'] += self.stats.get(key, {}).get('uploaded', 0)
+ self.stats['global']['completed'] += self.stats.get(key, {}).get('completed', 0)
del self.times[key]
del self.downloads[key]
del self.seedcount[key]
More information about the Debtorrent-commits
mailing list