Add 'tracker_host' torrent status key
This commit is contained in:
parent
a731da429b
commit
9930a311e7
|
@ -34,6 +34,7 @@
|
||||||
"""Internal Torrent class"""
|
"""Internal Torrent class"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from urlparse import urlparse
|
||||||
|
|
||||||
import deluge.libtorrent as lt
|
import deluge.libtorrent as lt
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -377,7 +378,22 @@ class Torrent:
|
||||||
ret.append(0.0)
|
ret.append(0.0)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def get_tracker_host(self):
|
||||||
|
"""Returns just the hostname of the currently connected tracker"""
|
||||||
|
if not self.status:
|
||||||
|
self.status = self.handle.status()
|
||||||
|
|
||||||
|
if self.status.current_tracker:
|
||||||
|
url = urlparse(self.status.current_tracker)
|
||||||
|
if hasattr(url, "hostname"):
|
||||||
|
host = (url.hostname or 'unknown?')
|
||||||
|
parts = host.split(".")
|
||||||
|
if len(parts) > 2:
|
||||||
|
host = ".".join(parts[-2:])
|
||||||
|
return host
|
||||||
|
return ""
|
||||||
|
|
||||||
def get_status(self, keys):
|
def get_status(self, keys):
|
||||||
"""Returns the status of the torrent based on the keys provided"""
|
"""Returns the status of the torrent based on the keys provided"""
|
||||||
# Create the full dictionary
|
# Create the full dictionary
|
||||||
|
@ -445,6 +461,7 @@ class Torrent:
|
||||||
"queue": self.handle.queue_position,
|
"queue": self.handle.queue_position,
|
||||||
"is_seed": self.handle.is_seed,
|
"is_seed": self.handle.is_seed,
|
||||||
"peers": self.get_peers,
|
"peers": self.get_peers,
|
||||||
|
"tracker_host": self.get_tracker_host
|
||||||
}
|
}
|
||||||
|
|
||||||
self.status = None
|
self.status = None
|
||||||
|
|
|
@ -99,20 +99,6 @@ def cell_data_queue(column, cell, model, row, data):
|
||||||
cell.set_property("text", "")
|
cell.set_property("text", "")
|
||||||
else:
|
else:
|
||||||
cell.set_property("text", value + 1)
|
cell.set_property("text", value + 1)
|
||||||
|
|
||||||
def cell_data_tracker(column, cell, model, row, data):
|
|
||||||
value = model.get_value(row, data)
|
|
||||||
if value:
|
|
||||||
url = urlparse(value)
|
|
||||||
if hasattr(url, "hostname"):
|
|
||||||
host = (url.hostname or 'unknown?')
|
|
||||||
parts = host.split(".")
|
|
||||||
if len(parts) > 2:
|
|
||||||
host = ".".join(parts[-2:])
|
|
||||||
cell.set_property("text", host)
|
|
||||||
return
|
|
||||||
|
|
||||||
cell.set_property("text", "")
|
|
||||||
|
|
||||||
class TorrentView(listview.ListView, component.Component):
|
class TorrentView(listview.ListView, component.Component):
|
||||||
"""TorrentView handles the listing of torrents."""
|
"""TorrentView handles the listing of torrents."""
|
||||||
|
@ -179,11 +165,8 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
listview.cell_data_ratio,
|
listview.cell_data_ratio,
|
||||||
[float],
|
[float],
|
||||||
status_field=["distributed_copies"])
|
status_field=["distributed_copies"])
|
||||||
|
self.add_text_column(_("Tracker"), status_field=["tracker_host"])
|
||||||
|
|
||||||
self.add_func_column(_("Tracker"),
|
|
||||||
cell_data_tracker,
|
|
||||||
[str],
|
|
||||||
status_field=["tracker"])
|
|
||||||
# Set default sort column to #
|
# Set default sort column to #
|
||||||
self.liststore.set_sort_column_id(self.get_column_index("#"), gtk.SORT_ASCENDING)
|
self.liststore.set_sort_column_id(self.get_column_index("#"), gtk.SORT_ASCENDING)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue