def start(self): Progress.start(self) self.setHasSub(self._hassub) self._ticking = True self._stopticking = False if self._hassub: self._currentcolumn.set_visible(False) self._totalcolumn.set_visible(False) self._speedcolumn.set_visible(False) thread.start_new_thread(self.tick, ())
def start(self): Progress.start(self) self.setHasSub(self._hassub) self._ticking = True self._stopticking = False if self._hassub: self._listview.hideColumn(self._currentcolumn) self._listview.hideColumn(self._totalcolumn) self._listview.hideColumn(self._speedcolumn) self._listview.hideColumn(self._etacolumn) thread.start_new_thread(self.tick, ())
def reloadChannels(self, channels=None, caching=ALWAYS): if channels is None: manual = False self.rebuildSysConfChannels() self.rebuildDynamicChannels() channels = self._channels.values() hooks.call("reload-channels", channels) else: manual = True # Get channels directory and check the necessary locks. channelsdir = os.path.join(sysconf.get("data-dir"), "channels/") userchannelsdir = os.path.join(sysconf.get("user-data-dir"), "channels/") if not os.path.isdir(channelsdir): try: os.makedirs(channelsdir) except OSError: raise Error, _("Unable to create channel directory.") if caching is ALWAYS: if sysconf.getReadOnly() and os.access(channelsdir, os.W_OK): iface.warning( _("The Smart library is already in use by " "another process.")) iface.warning(_("Configuration is in readonly mode!")) if not self._pathlocks.lock(channelsdir): raise Error, _("Channel information is locked for writing.") elif sysconf.getReadOnly(): raise Error, _("Can't update channels in readonly mode.") elif not self._pathlocks.lock(channelsdir, exclusive=True): raise Error, _("Can't update channels with active readers.") self._fetcher.setLocalDir(channelsdir, mangle=True) # Prepare progress. If we're reading from the cache, we don't want # too much information being shown. Otherwise, ask for a full-blown # progress for the interface, and build information of currently # available packages to compare later. if caching is ALWAYS: progress = Progress() else: progress = iface.getProgress(self._fetcher, True) oldpkgs = {} for pkg in self._cache.getPackages(): oldpkgs[(pkg.name, pkg.version)] = True progress.start() steps = 0 for channel in channels: steps += channel.getFetchSteps() progress.set(0, steps) # Rebuild mirror information. self.reloadMirrors() self._fetcher.setForceMountedCopy(True) self._cache.reset() # Do the real work. result = True for channel in channels: digest = channel.getDigest() if not manual and channel.hasManualUpdate(): self._fetcher.setCaching(ALWAYS) else: self._fetcher.setCaching(caching) if channel.getFetchSteps() > 0: progress.setTopic( _("Fetching information for '%s'...") % (channel.getName() or channel.getAlias())) progress.show() self._fetcher.setForceCopy(channel.isRemovable()) self._fetcher.setLocalPathPrefix(channel.getAlias() + "%%") try: if not channel.fetch(self._fetcher, progress): iface.debug(_("Failed fetching channel '%s'") % channel) result = False except Error, e: iface.error(unicode(e)) iface.debug(_("Failed fetching channel '%s'") % channel) result = False if (channel.getDigest() != digest and isinstance(channel, PackageChannel)): channel.addLoaders(self._cache) if channel.getAlias() in self._sysconfchannels: self._cachechanged = True
def reloadChannels(self, channels=None, caching=ALWAYS): if channels is None: manual = False self.rebuildSysConfChannels() self.rebuildDynamicChannels() channels = self._channels.values() hooks.call("reload-channels", channels) else: manual = True # Get channels directory and check the necessary locks. channelsdir = os.path.join(sysconf.get("data-dir"), "channels/") userchannelsdir = os.path.join(sysconf.get("user-data-dir"), "channels/") if not os.path.isdir(channelsdir): try: os.makedirs(channelsdir) except OSError: raise Error, _("Unable to create channel directory.") if caching is ALWAYS: if sysconf.getReadOnly() and os.access(channelsdir, os.W_OK): iface.warning(_("The Smart library is already in use by " "another process.")) iface.warning(_("Configuration is in readonly mode!")) if not self._pathlocks.lock(channelsdir): raise Error, _("Channel information is locked for writing.") elif sysconf.getReadOnly(): raise Error, _("Can't update channels in readonly mode.") elif not self._pathlocks.lock(channelsdir, exclusive=True): raise Error, _("Can't update channels with active readers.") self._fetcher.setLocalDir(channelsdir, mangle=True) # Prepare progress. If we're reading from the cache, we don't want # too much information being shown. Otherwise, ask for a full-blown # progress for the interface, and build information of currently # available packages to compare later. if caching is ALWAYS: progress = Progress() else: progress = iface.getProgress(self._fetcher, True) oldpkgs = {} for pkg in self._cache.getPackages(): oldpkgs[(pkg.name, pkg.version)] = True progress.start() steps = 0 for channel in channels: steps += channel.getFetchSteps() progress.set(0, steps) # Rebuild mirror information. self.reloadMirrors() self._fetcher.setForceMountedCopy(True) self._cache.reset() # Do the real work. result = True for channel in channels: digest = channel.getDigest() if not manual and channel.hasManualUpdate(): self._fetcher.setCaching(ALWAYS) else: self._fetcher.setCaching(caching) if channel.getFetchSteps() > 0: progress.setTopic(_("Fetching information for '%s'...") % (channel.getName() or channel.getAlias())) progress.show() self._fetcher.setForceCopy(channel.isRemovable()) self._fetcher.setLocalPathPrefix(channel.getAlias()+"%%") try: if not channel.fetch(self._fetcher, progress): iface.debug(_("Failed fetching channel '%s'") % channel) result = False except Error, e: iface.error(unicode(e)) iface.debug(_("Failed fetching channel '%s'") % channel) result = False if (channel.getDigest() != digest and isinstance(channel, PackageChannel)): channel.addLoaders(self._cache) if channel.getAlias() in self._sysconfchannels: self._cachechanged = True