Module: deluge
Branch: master
Commit: e0bb8869aa65495d23dcc5c42ed387c97a3d6d45

Author: Nick Lanham <[email protected]>
Date:   Tue Mar  8 11:34:59 2011 +0100

add some more columns

---

 deluge/ui/console/modes/alltorrents.py  |   38 +++++++++++++++++++++++++++---
 deluge/ui/console/modes/column.py       |   18 +++++++++++++-
 deluge/ui/console/modes/format_utils.py |   14 +++++++++++
 3 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/deluge/ui/console/modes/alltorrents.py 
b/deluge/ui/console/modes/alltorrents.py
index 5f29937..778ffa4 100644
--- a/deluge/ui/console/modes/alltorrents.py
+++ b/deluge/ui/console/modes/alltorrents.py
@@ -141,6 +141,15 @@ DEFAULT_PREFS = {
     "show_peers":True,
     "show_downspeed":True,
     "show_upspeed":True,
+    "show_eta":False,
+    "show_ratio":False,
+    "show_avail":False,
+    "show_added":False,
+    "show_tracker":False,
+    "show_savepath":False,
+    "show_downloaded":False,
+    "show_uploaded":False,
+    "show_owner":False,
     "queue_width":5,
     "name_width":-1,
     "size_width":15,
@@ -150,11 +159,23 @@ DEFAULT_PREFS = {
     "peers_width":10,
     "downspeed_width":15,
     "upspeed_width":15,
+    "eta_width":10,
+    "ratio_width":10,
+    "avail_width":10,
+    "added_width":25,
+    "tracker_width":15,
+    "savepath_width":15,
+    "downloaded_width":13,
+    "uploaded_width":13,
+    "owner_width":10,
 }
 
 column_pref_names = ["queue","name","size","state",
                      "progress","seeders","peers",
-                     "downspeed","upspeed"]
+                     "downspeed","upspeed","eta",
+                     "ratio","avail","added","tracker",
+                     "savepath","downloaded","uploaded",
+                     "owner"]
 
 prefs_to_names = {
     "queue":"#", 
@@ -165,7 +186,16 @@ prefs_to_names = {
     "seeders":"Seeders",
     "peers":"Peers",
     "downspeed":"Down Speed",
-    "upspeed":"Up Speed"
+    "upspeed":"Up Speed",
+    "eta":"ETA",
+    "ratio":"Ratio",
+    "avail":"Avail",
+    "added":"Added",
+    "tracker":"Tracker",
+    "savepath":"Save Path",
+    "downloaded":"Downloaded",
+    "uploaded":"Uploaded",
+    "owner":"Owner",
 }
 
 class AllTorrents(BaseMode, component.Component):
@@ -214,13 +244,13 @@ class AllTorrents(BaseMode, component.Component):
             ("Path", None, ("save_path",)),
             ("Downloaded",deluge.common.fsize,("all_time_download",)),
             ("Uploaded", deluge.common.fsize,("total_uploaded",)),
-            ("Share Ratio", lambda x:x < 0 and "∞" or "%.3f"%x, ("ratio",)),
+            ("Share Ratio", format_utils.format_float, ("ratio",)),
             
("Seeders",format_utils.format_seeds_peers,("num_seeds","total_seeds")),
             
("Peers",format_utils.format_seeds_peers,("num_peers","total_peers")),
             ("Active Time",deluge.common.ftime,("active_time",)),
             ("Seeding Time",deluge.common.ftime,("seeding_time",)),
             ("Date Added",deluge.common.fdate,("time_added",)),
-            ("Availability", lambda x:x < 0 and "∞" or "%.3f"%x, 
("distributed_copies",)),
+            ("Availability", format_utils.format_float, 
("distributed_copies",)),
             ("Pieces", format_utils.format_pieces, 
("num_pieces","piece_length")),
             ]
 
diff --git a/deluge/ui/console/modes/column.py 
b/deluge/ui/console/modes/column.py
index f1eb327..fcc7878 100644
--- a/deluge/ui/console/modes/column.py
+++ b/deluge/ui/console/modes/column.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 #
 # column.py
 #
@@ -36,6 +37,10 @@
 import deluge.common
 import format_utils
 
+import logging
+log = logging.getLogger(__name__)
+
+
 def format_queue(qnum):
     if (qnum >= 0):
         return "%d"%(qnum+1)
@@ -52,13 +57,22 @@ columns = {
     "Peers":(("num_peers","total_peers"),format_utils.format_seeds_peers),
     "Down Speed":(("download_payload_rate",),format_utils.format_speed),
     "Up Speed":(("upload_payload_rate",),format_utils.format_speed),
+    "ETA":(("eta",), format_utils.format_time),
+    "Ratio":(("ratio",), format_utils.format_float),
+    "Avail":(("distributed_copies",), format_utils.format_float),
+    "Added":(("time_added",), deluge.common.fdate),
+    "Tracker":(("tracker_host",), None),
+    "Save Path":(("save_path",), None),
+    "Downloaded":(("all_time_download",), deluge.common.fsize),
+    "Uploaded":(("total_uploaded",), deluge.common.fsize),
+    "Owner":(("owner",),None)
     }
 
 def get_column_value(name,state):
     try:
         col = columns[name]
     except KeyError:
-        log.debug("No such column: %s",name)
+        log.error("No such column: %s",name)
         return None
 
     if col[1] != None:
@@ -67,7 +81,7 @@ def get_column_value(name,state):
             for key in col[0]:
                 args.append(state[key])
         except:
-            log.debug("Could not get column field: %s",col[1])
+            log.error("Could not get column field: %s",col[0])
             return None
         colval = col[1](*args)
     else:
diff --git a/deluge/ui/console/modes/format_utils.py 
b/deluge/ui/console/modes/format_utils.py
index 73a5ec0..826d514 100644
--- a/deluge/ui/console/modes/format_utils.py
+++ b/deluge/ui/console/modes/format_utils.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+#
 # format_utils.py
 #
 # Copyright (C) 2011 Nick Lanham <[email protected]>
@@ -45,6 +47,18 @@ def format_speed(speed):
     else:
         return "-"
 
+def format_time(time):
+    if (time > 0):
+        return deluge.common.ftime(time)
+    else:
+        return "-"
+
+def format_float(x):
+    if x < 0:
+        return "∞"
+    else:
+        return "%.3f"%x
+
 def format_seeds_peers(num, total):
     return "%d (%d)"%(num,total)
 

-- 
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