Fixes for #607 : Add completed_time to core and Completed column in GTK UI
This commit is contained in:
parent
0da6739f94
commit
169b9b9898
|
@ -54,6 +54,7 @@ TORRENT_STATE = deluge.common.TORRENT_STATE
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def sanitize_filepath(filepath, folder=False):
|
||||
"""
|
||||
Returns a sanitized filepath to pass to libotorrent rename_file().
|
||||
|
@ -79,6 +80,7 @@ def sanitize_filepath(filepath, folder=False):
|
|||
else:
|
||||
return newfilepath
|
||||
|
||||
|
||||
class TorrentOptions(dict):
|
||||
def __init__(self):
|
||||
config = ConfigManager("core.conf").config
|
||||
|
@ -105,6 +107,7 @@ class TorrentOptions(dict):
|
|||
self["file_priorities"] = []
|
||||
self["mapped_files"] = {}
|
||||
|
||||
|
||||
class Torrent(object):
|
||||
"""Torrent holds information about torrents added to the libtorrent session.
|
||||
"""
|
||||
|
@ -381,7 +384,7 @@ class Torrent(object):
|
|||
|
||||
def set_trackers(self, trackers):
|
||||
"""Sets trackers"""
|
||||
if trackers == None:
|
||||
if trackers is None:
|
||||
trackers = []
|
||||
for value in self.handle.trackers():
|
||||
tracker = {}
|
||||
|
@ -574,7 +577,7 @@ class Torrent(object):
|
|||
|
||||
file_progress = self.handle.file_progress()
|
||||
ret = []
|
||||
for i,f in enumerate(self.get_files()):
|
||||
for i, f in enumerate(self.get_files()):
|
||||
try:
|
||||
ret.append(float(file_progress[i]) / float(f["size"]))
|
||||
except ZeroDivisionError:
|
||||
|
@ -680,8 +683,8 @@ class Torrent(object):
|
|||
"active_time": lambda: self.status.active_time,
|
||||
"all_time_download": lambda: self.status.all_time_download,
|
||||
"compact": lambda: self.options["compact_allocation"],
|
||||
"distributed_copies": lambda: 0.0 if self.status.distributed_copies < 0 else \
|
||||
self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value
|
||||
"distributed_copies": lambda: 0.0 if self.status.distributed_copies < 0 else
|
||||
self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value
|
||||
"download_payload_rate": lambda: self.status.download_payload_rate,
|
||||
"file_priorities": lambda: self.options["file_priorities"],
|
||||
"hash": lambda: self.torrent_id,
|
||||
|
@ -708,8 +711,8 @@ class Torrent(object):
|
|||
"remove_at_ratio": lambda: self.options["remove_at_ratio"],
|
||||
"save_path": lambda: self.options["download_location"],
|
||||
"seeding_time": lambda: self.status.seeding_time,
|
||||
"seeds_peers_ratio": lambda: -1.0 if self.status.num_incomplete == 0 else \
|
||||
self.status.num_complete / float(self.status.num_incomplete), # Use -1.0 to signify infinity
|
||||
"seeds_peers_ratio": lambda: -1.0 if self.status.num_incomplete == 0 else
|
||||
self.status.num_complete / float(self.status.num_incomplete), # Use -1.0 to signify infinity
|
||||
"seed_rank": lambda: self.status.seed_rank,
|
||||
"state": lambda: self.state,
|
||||
"stop_at_ratio": lambda: self.options["stop_at_ratio"],
|
||||
|
@ -734,18 +737,18 @@ class Torrent(object):
|
|||
"private": lambda: self.torrent_info.priv() if self.has_metadata else False,
|
||||
"total_size": lambda: self.torrent_info.total_size() if self.has_metadata else 0,
|
||||
"eta": self.get_eta,
|
||||
"file_progress": self.get_file_progress, # Adjust progress to be 0-100 value
|
||||
"file_progress": self.get_file_progress, # Adjust progress to be 0-100 value
|
||||
"files": self.get_files,
|
||||
"is_seed": lambda: self.status.is_seeding,
|
||||
"peers": self.get_peers,
|
||||
"queue": self.handle.queue_position,
|
||||
"ratio": self.get_ratio,
|
||||
"tracker_host": self.get_tracker_host,
|
||||
"completed_time": lambda: self.status.completed_time,
|
||||
"last_seen_complete": lambda: self.status.last_seen_complete,
|
||||
"name": self.get_name,
|
||||
"pieces": self._get_pieces_info,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
def get_name(self):
|
||||
if self.has_metadata:
|
||||
|
|
|
@ -54,6 +54,7 @@ import torrentview_data_funcs as funcs
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def queue_peer_seed_sort_function(v1, v2):
|
||||
if v1 == v2:
|
||||
return 0
|
||||
|
@ -66,6 +67,7 @@ def queue_peer_seed_sort_function(v1, v2):
|
|||
if v2 > v1:
|
||||
return -1
|
||||
|
||||
|
||||
def queue_column_sort(model, iter1, iter2, data):
|
||||
v1 = model[iter1][data]
|
||||
v2 = model[iter2][data]
|
||||
|
@ -86,6 +88,7 @@ def eta_column_sort(model, iter1, iter2, data):
|
|||
if v2 > v1:
|
||||
return -1
|
||||
|
||||
|
||||
def seed_peer_column_sort(model, iter1, iter2, data):
|
||||
v1 = model[iter1][data] # num seeds/peers
|
||||
v3 = model[iter2][data] # num seeds/peers
|
||||
|
@ -95,6 +98,7 @@ def seed_peer_column_sort(model, iter1, iter2, data):
|
|||
return queue_peer_seed_sort_function(v2, v4)
|
||||
return queue_peer_seed_sort_function(v1, v3)
|
||||
|
||||
|
||||
class SearchBox(object):
|
||||
def __init__(self, torrentview):
|
||||
self.torrentview = torrentview
|
||||
|
@ -183,7 +187,6 @@ class SearchBox(object):
|
|||
self.prefiltered.pop(self.prefiltered.index(torrent_id))
|
||||
row[filter_column] = not row[filter_column]
|
||||
|
||||
|
||||
if not row[filter_column]:
|
||||
# Row is not visible(filtered out, but not by our filter), skip it
|
||||
continue
|
||||
|
@ -294,6 +297,9 @@ class TorrentView(listview.ListView, component.Component):
|
|||
status_field=["distributed_copies"], default=False)
|
||||
self.add_func_column(_("Added"), funcs.cell_data_date, [float],
|
||||
status_field=["time_added"], default=False)
|
||||
self.add_func_column(_("Completed"),
|
||||
funcs.cell_data_date_or_never, [float],
|
||||
status_field=["completed_time"], default=False)
|
||||
self.add_func_column(_("Last Seen Complete"),
|
||||
funcs.cell_data_date_or_never, [float],
|
||||
status_field=["last_seen_complete"], default=False)
|
||||
|
@ -393,7 +399,7 @@ class TorrentView(listview.ListView, component.Component):
|
|||
"""
|
||||
self.treeview.get_selection().unselect_all()
|
||||
search_filter = self.filter and self.filter.get('name', None) or None
|
||||
self.filter = dict(filter_dict) #copied version of filter_dict.
|
||||
self.filter = dict(filter_dict) # Copied version of filter_dict.
|
||||
if search_filter and 'name' not in filter_dict:
|
||||
self.filter['name'] = search_filter
|
||||
self.update()
|
||||
|
@ -411,8 +417,8 @@ class TorrentView(listview.ListView, component.Component):
|
|||
# Make sure column is visible and has 'status_field' set.
|
||||
# If not, we can ignore it.
|
||||
if self.columns[column].column.get_visible() is True \
|
||||
and self.columns[column].hidden is False \
|
||||
and self.columns[column].status_field is not None:
|
||||
and self.columns[column].hidden is False \
|
||||
and self.columns[column].status_field is not None:
|
||||
for field in self.columns[column].status_field:
|
||||
status_keys.append(field)
|
||||
self.columns_to_update.append(column)
|
||||
|
@ -478,7 +484,7 @@ class TorrentView(listview.ListView, component.Component):
|
|||
if torrent_status == self.prev_status[torrent_id]:
|
||||
# The status dict is the same, so do nothing to update for this torrent
|
||||
continue
|
||||
except KeyError, e:
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if not torrent_id_in_status:
|
||||
|
@ -539,12 +545,13 @@ class TorrentView(listview.ListView, component.Component):
|
|||
self.update()
|
||||
break
|
||||
|
||||
def mark_dirty(self, torrent_id = None):
|
||||
def mark_dirty(self, torrent_id=None):
|
||||
for row in self.liststore:
|
||||
if not torrent_id or row[self.columns["torrent_id"].column_indices[0]] == torrent_id:
|
||||
#log.debug("marking %s dirty", torrent_id)
|
||||
row[self.columns["dirty"].column_indices[0]] = True
|
||||
if torrent_id: break
|
||||
if torrent_id:
|
||||
break
|
||||
|
||||
def get_selected_torrent(self):
|
||||
"""Returns a torrent_id or None. If multiple torrents are selected,
|
||||
|
@ -610,7 +617,8 @@ class TorrentView(listview.ListView, component.Component):
|
|||
row = self.model_filter.get_iter(path[0])
|
||||
|
||||
if self.get_selected_torrents():
|
||||
if self.model_filter.get_value(row, self.columns["torrent_id"].column_indices[0]) not in self.get_selected_torrents():
|
||||
if self.model_filter.get_value(row, self.columns["torrent_id"].column_indices[0]) \
|
||||
not in self.get_selected_torrents():
|
||||
self.treeview.get_selection().unselect_all()
|
||||
self.treeview.get_selection().select_iter(row)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue