Module: deluge
Branch: master
Commit: 85b4ceec3002f184e9a9b69fd4dc28a31cfa4d6d

Author: Calum Lind <[email protected]>
Date:   Sun May 22 22:48:03 2011 +0100

Feature #1308: Add Seeds/Peers ratio to torrent list view

---

 deluge/core/torrent.py         |    8 ++++++++
 deluge/ui/gtkui/torrentview.py |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index 5db3a4c..723b7c5 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -620,6 +620,13 @@ class Torrent(object):
         if distributed_copies < 0:
             distributed_copies = 0.0
 
+        # Calculate the seeds:peers ratio
+        if self.status.num_incomplete == 0:
+            # Use -1.0 to signify infinity
+            seeds_peers_ratio = -1.0
+        else:
+            seeds_peers_ratio = self.status.num_complete / 
float(self.status.num_incomplete)
+
         full_status = {
             "active_time": self.status.active_time,
             "all_time_download": self.status.all_time_download,
@@ -651,6 +658,7 @@ class Torrent(object):
             "remove_at_ratio": self.options["remove_at_ratio"],
             "save_path": self.options["download_location"],
             "seeding_time": self.status.seeding_time,
+            "seeds_peers_ratio": seeds_peers_ratio,
             "seed_rank": self.status.seed_rank,
             "state": self.state,
             "stop_at_ratio": self.options["stop_at_ratio"],
diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py
index bc0f992..b95402a 100644
--- a/deluge/ui/gtkui/torrentview.py
+++ b/deluge/ui/gtkui/torrentview.py
@@ -235,6 +235,8 @@ class TorrentView(listview.ListView, component.Component):
         self.add_func_column(_("Peers"), listview.cell_data_peer, [int, int],
                              status_field=["num_peers", "total_peers"],
                              sort_func=seed_peer_column_sort)
+        self.add_func_column(_("Seeders") + "/" + _("Peers"), 
listview.cell_data_ratio, [float],
+                             status_field=["seeds_peers_ratio"])
         self.add_func_column(_("Down Speed"), listview.cell_data_speed, 
[float],
                              status_field=["download_payload_rate"])
         self.add_func_column(_("Up Speed"), listview.cell_data_speed, [float],

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to