Beispiel #1
0
 def queue_bottom(self, torrent_ids):
     log.debug('Attempting to queue %s to bottom', torrent_ids)
     # torrent_ids must be sorted before moving to preserve order
     for torrent_id in sorted(torrent_ids, key=self.torrentmanager.get_queue_position):
         try:
             # If the queue method returns True, then we should emit a signal
             if self.torrentmanager.queue_bottom(torrent_id):
                 component.get('EventManager').emit(TorrentQueueChangedEvent())
         except KeyError:
             log.warning('torrent_id: %s does not exist in the queue', torrent_id)
Beispiel #2
0
 def queue_down(self, torrent_ids):
     log.debug('Attempting to queue %s to down', torrent_ids)
     torrents = ((self.torrentmanager.get_queue_position(torrent_id), torrent_id) for torrent_id in torrent_ids)
     torrent_moved = True
     prev_queue_position = None
     # torrent_ids must be sorted before moving.
     for queue_position, torrent_id in sorted(torrents, reverse=True):
         # Move the torrent if and only if there is space (by not moving it we preserve the order)
         if torrent_moved or prev_queue_position - queue_position > 1:
             try:
                 torrent_moved = self.torrentmanager.queue_down(torrent_id)
             except KeyError:
                 log.warning('torrent_id: %s does not exist in the queue', torrent_id)
         # If the torrent moved, then we should emit a signal
         if torrent_moved:
             component.get('EventManager').emit(TorrentQueueChangedEvent())
         else:
             prev_queue_position = queue_position