summaryrefslogtreecommitdiffstats
path: root/deluge/core/core.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2017-06-28 22:30:16 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2018-06-18 20:06:35 +0100
commit3176b877a415edf0119fef3deeeddde9361a590b (patch)
tree43e22f8ce3a1a10ddc734fb9847aecb70b583ce5 /deluge/core/core.py
parent18541bce860c6e9e8059338abf38d1df9df768ea (diff)
downloaddeluge-3176b877a415edf0119fef3deeeddde9361a590b.tar.gz
deluge-3176b877a415edf0119fef3deeeddde9361a590b.tar.bz2
deluge-3176b877a415edf0119fef3deeeddde9361a590b.zip
[Core] Add methods pause_torrents & resume_torrents
Diffstat (limited to 'deluge/core/core.py')
-rw-r--r--deluge/core/core.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/deluge/core/core.py b/deluge/core/core.py
index db20f6d29..2662ad221 100644
--- a/deluge/core/core.py
+++ b/deluge/core/core.py
@@ -600,11 +600,20 @@ class Core(component.Component):
self.torrentmanager[torrent_id].force_reannounce()
@export
- def pause_torrent(self, torrent_ids):
- log.debug('Pausing: %s', torrent_ids)
+ def pause_torrent(self, torrent_id):
+ """Pauses a torrent"""
+ log.debug('Pausing: %s', torrent_id)
+ if not isinstance(torrent_id, str if not PY2 else basestring):
+ self.pause_torrents(torrent_id)
+ self.torrentmanager[torrent_id].pause()
+
+ @export
+ def pause_torrents(self, torrent_ids=None):
+ """Pauses a list of torrents"""
+ if not torrent_ids:
+ torrent_ids = self.torrentmanager.get_torrent_list()
for torrent_id in torrent_ids:
- if not self.torrentmanager[torrent_id].pause():
- log.warning('Error pausing torrent %s', torrent_id)
+ self.pause_torrent(torrent_id)
@export
def connect_peer(self, torrent_id, ip, port):
@@ -636,10 +645,20 @@ class Core(component.Component):
component.get('EventManager').emit(SessionResumedEvent())
@export
- def resume_torrent(self, torrent_ids):
- log.debug('Resuming: %s', torrent_ids)
+ def resume_torrent(self, torrent_id):
+ """Resumes a torrent"""
+ log.debug('Resuming: %s', torrent_id)
+ if not isinstance(torrent_id, str if not PY2 else basestring):
+ self.resume_torrents(torrent_id)
+ self.torrentmanager[torrent_id].resume()
+
+ @export
+ def resume_torrents(self, torrent_ids=None):
+ """Resumes a list of torrents"""
+ if not torrent_ids:
+ torrent_ids = self.torrentmanager.get_torrent_list()
for torrent_id in torrent_ids:
- self.torrentmanager[torrent_id].resume()
+ self.resume_torrent(torrent_id)
def create_torrent_status(self, torrent_id, torrent_keys, plugin_keys, diff=False, update=False, all_keys=False):
try: