From ca1eaa5e15c989f431c2c5978a696176cb86e19b Mon Sep 17 00:00:00 2001 From: bendikro Date: Mon, 8 Sep 2014 18:43:14 +0200 Subject: [PATCH] [Core] Add TorrentTrackerStatusEvent --- deluge/core/torrent.py | 10 ++++++++-- deluge/event.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 43a0a1ab1..3e00b06bf 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -29,7 +29,7 @@ from deluge._libtorrent import lt from deluge.common import decode_string, utf8_encoded from deluge.configmanager import ConfigManager, get_config_dir from deluge.core.authmanager import AUTH_LEVEL_ADMIN -from deluge.event import TorrentFolderRenamedEvent, TorrentStateChangedEvent +from deluge.event import TorrentFolderRenamedEvent, TorrentStateChangedEvent, TorrentTrackerStatusEvent log = logging.getLogger(__name__) @@ -602,10 +602,16 @@ class Torrent(object): Args: status (str): The tracker status. + Emits: + TorrentTrackerStatusEvent upon tracker status change. + """ self.tracker_host = None - self.tracker_status = status + + if self.tracker_status != status: + self.tracker_status = status + component.get("EventManager").emit(TorrentTrackerStatusEvent(self.torrent_id, self.tracker_status)) def merge_trackers(self, torrent_info): """Merges new trackers in torrent_info into torrent""" diff --git a/deluge/event.py b/deluge/event.py index b916a5cee..072345bfd 100644 --- a/deluge/event.py +++ b/deluge/event.py @@ -104,6 +104,19 @@ class TorrentStateChangedEvent(DelugeEvent): self._args = [torrent_id, state] +class TorrentTrackerStatusEvent(DelugeEvent): + """ + Emitted when a torrents tracker status changes. + """ + def __init__(self, torrent_id, status): + """ + Args: + torrent_id (str): the torrent_id + status (str): the new status + """ + self._args = [torrent_id, status] + + class TorrentQueueChangedEvent(DelugeEvent): """ Emitted when the queue order has changed.