add some more columns
This commit is contained in:
parent
255af3c485
commit
e0bb8869aa
|
@ -141,6 +141,15 @@ DEFAULT_PREFS = {
|
||||||
"show_peers":True,
|
"show_peers":True,
|
||||||
"show_downspeed":True,
|
"show_downspeed":True,
|
||||||
"show_upspeed":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,
|
"queue_width":5,
|
||||||
"name_width":-1,
|
"name_width":-1,
|
||||||
"size_width":15,
|
"size_width":15,
|
||||||
|
@ -150,11 +159,23 @@ DEFAULT_PREFS = {
|
||||||
"peers_width":10,
|
"peers_width":10,
|
||||||
"downspeed_width":15,
|
"downspeed_width":15,
|
||||||
"upspeed_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",
|
column_pref_names = ["queue","name","size","state",
|
||||||
"progress","seeders","peers",
|
"progress","seeders","peers",
|
||||||
"downspeed","upspeed"]
|
"downspeed","upspeed","eta",
|
||||||
|
"ratio","avail","added","tracker",
|
||||||
|
"savepath","downloaded","uploaded",
|
||||||
|
"owner"]
|
||||||
|
|
||||||
prefs_to_names = {
|
prefs_to_names = {
|
||||||
"queue":"#",
|
"queue":"#",
|
||||||
|
@ -165,7 +186,16 @@ prefs_to_names = {
|
||||||
"seeders":"Seeders",
|
"seeders":"Seeders",
|
||||||
"peers":"Peers",
|
"peers":"Peers",
|
||||||
"downspeed":"Down Speed",
|
"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):
|
class AllTorrents(BaseMode, component.Component):
|
||||||
|
@ -214,13 +244,13 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
("Path", None, ("save_path",)),
|
("Path", None, ("save_path",)),
|
||||||
("Downloaded",deluge.common.fsize,("all_time_download",)),
|
("Downloaded",deluge.common.fsize,("all_time_download",)),
|
||||||
("Uploaded", deluge.common.fsize,("total_uploaded",)),
|
("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")),
|
("Seeders",format_utils.format_seeds_peers,("num_seeds","total_seeds")),
|
||||||
("Peers",format_utils.format_seeds_peers,("num_peers","total_peers")),
|
("Peers",format_utils.format_seeds_peers,("num_peers","total_peers")),
|
||||||
("Active Time",deluge.common.ftime,("active_time",)),
|
("Active Time",deluge.common.ftime,("active_time",)),
|
||||||
("Seeding Time",deluge.common.ftime,("seeding_time",)),
|
("Seeding Time",deluge.common.ftime,("seeding_time",)),
|
||||||
("Date Added",deluge.common.fdate,("time_added",)),
|
("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")),
|
("Pieces", format_utils.format_pieces, ("num_pieces","piece_length")),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# column.py
|
# column.py
|
||||||
#
|
#
|
||||||
|
@ -36,6 +37,10 @@
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import format_utils
|
import format_utils
|
||||||
|
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def format_queue(qnum):
|
def format_queue(qnum):
|
||||||
if (qnum >= 0):
|
if (qnum >= 0):
|
||||||
return "%d"%(qnum+1)
|
return "%d"%(qnum+1)
|
||||||
|
@ -52,13 +57,22 @@ columns = {
|
||||||
"Peers":(("num_peers","total_peers"),format_utils.format_seeds_peers),
|
"Peers":(("num_peers","total_peers"),format_utils.format_seeds_peers),
|
||||||
"Down Speed":(("download_payload_rate",),format_utils.format_speed),
|
"Down Speed":(("download_payload_rate",),format_utils.format_speed),
|
||||||
"Up Speed":(("upload_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):
|
def get_column_value(name,state):
|
||||||
try:
|
try:
|
||||||
col = columns[name]
|
col = columns[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.debug("No such column: %s",name)
|
log.error("No such column: %s",name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if col[1] != None:
|
if col[1] != None:
|
||||||
|
@ -67,7 +81,7 @@ def get_column_value(name,state):
|
||||||
for key in col[0]:
|
for key in col[0]:
|
||||||
args.append(state[key])
|
args.append(state[key])
|
||||||
except:
|
except:
|
||||||
log.debug("Could not get column field: %s",col[1])
|
log.error("Could not get column field: %s",col[0])
|
||||||
return None
|
return None
|
||||||
colval = col[1](*args)
|
colval = col[1](*args)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
# format_utils.py
|
# format_utils.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
|
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
|
||||||
|
@ -45,6 +47,18 @@ def format_speed(speed):
|
||||||
else:
|
else:
|
||||||
return "-"
|
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):
|
def format_seeds_peers(num, total):
|
||||||
return "%d (%d)"%(num,total)
|
return "%d (%d)"%(num,total)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue