def finished(self, torrent): """Launch the auto-updater""" self.debug('finished() called for ' + infohash_short(torrent.infohash)) if self.butles(torrent): self.debug('finished() setting installable version to ' + infohash_short(torrent.infohash)) self.installable_version = torrent.infohash
def butle(self): for i in list(self.estate): try: t = self.multitorrent.get_torrent(i) if t.state == 'initialized': self.multitorrent.start_torrent(t.infohash) torrent, status = self.multitorrent.torrent_status(i) if torrent.completed: self.finished(t) except UnknownInfohash: self.debug('butle() removing ' + infohash_short(i)) self.estate.remove(i) self.installable_version = None self.available_version = None for v, i in list(self.old_updates): self.old_updates.discard((v, i)) self.logger.warning(_("Cleaning up old autoupdate %s") % v) try: self.multitorrent.remove_torrent(i, del_files=True) except UnknownInfohash: pass
installer_path, hidden=True, is_auto_update=True) yield df df.getResult() except TorrentAlreadyRunning: self.debug(debug_prefix + 'found auto-update torrent already running') except TorrentAlreadyInQueue: self.debug(debug_prefix + 'found auto-update torrent queued') else: self.debug(debug_prefix + 'starting auto-update download') self.debug(debug_prefix + 'adding to estate ' + infohash_short(infohash)) self.estate.add(infohash) else: self.debug(debug_prefix + 'torrent file signature failed to verify.') pass else: self.debug(debug_prefix + 'couldn\'t get both torrentfile %s and signature %s' % (str(type(torrentfile)), str(type(signature)))) self._restart() def _restart(self):
self.multitorrent.remove_auto_updates_except(infohash) try: df = self.multitorrent.create_torrent(metainfo, installer_path, installer_path, hidden=True, is_auto_update=True) yield df df.getResult() except TorrentAlreadyRunning: self.debug(debug_prefix + 'found auto-update torrent already running') except TorrentAlreadyInQueue: self.debug(debug_prefix + 'found auto-update torrent queued') else: self.debug(debug_prefix + 'starting auto-update download') self.debug(debug_prefix + 'adding to estate ' + infohash_short(infohash)) self.estate.add(infohash) else: self.debug(debug_prefix + 'torrent file signature failed to verify.') pass else: self.debug(debug_prefix + 'couldn\'t get both torrentfile %s and signature %s' % (str(type(torrentfile)), str(type(signature)))) self._restart()