def pulse(self): FetchProgress.pulse(self) self.label.set_text("Speed: %s/s" % apt_pkg.SizeToStr(self.currentCPS)) #self.progressbar.set_fraction(self.currentBytes/self.totalBytes) while gtk.events_pending(): gtk.main_iteration() return True
def pulse(self): FetchProgress.pulse(self) if self.currentCPS > 0: s = "%sB/s %s" % (apt_pkg.SizeToStr(int(self.currentCPS)), apt_pkg.TimeToStr(int(self.eta))) else: s = "[Working..]" self.status_label.setText(s) self.pbar.setValue(int(self.percent)) QtGui.qApp.processEvents() return True
def pulse(self): FetchProgress.pulse(self) if self.currentCPS > 0: s = "[%2.f%%] %sB/s %s" % (self.percent, apt_pkg.SizeToStr(int(self.currentCPS)), apt_pkg.TimeToStr(int(self.eta))) else: s = "%2.f%% [Working]" % (self.percent) print "\r%s" % (s), sys.stdout.flush() return True
def pulse(self): apt.progress.FetchProgress.pulse(self) if self.currentCPS > 0: info = self.frontend.get_string('apt_progress_cps') info = info.replace('${SPEED}', apt_pkg.SizeToStr(self.currentCPS)) else: info = self.frontend.get_string('apt_progress') info = info.replace('${INDEX}', str(self.currentItems)) info = info.replace('${TOTAL}', str(self.totalItems)) self.frontend.debconf_progress_info(info) self.frontend.debconf_progress_set(self.percent) self.frontend.refresh() return True
def confirmChanges(self, summary, changes, downloadSize, actions=None): DistUpgradeView.confirmChanges(self, summary, changes, downloadSize, actions) pkgs_remove = len(self.toRemove) pkgs_inst = len(self.toInstall) pkgs_upgrade = len(self.toUpgrade) msg = "" if pkgs_remove > 0: # FIXME: make those two seperate lines to make it clear # that the "%" applies to the result of ngettext msg += gettext.ngettext("%d package is going to be removed.", "%d packages are going to be removed.", pkgs_remove) % pkgs_remove msg += " " if pkgs_inst > 0: msg += gettext.ngettext( "%d new package is going to be " "installed.", "%d new packages are going to be " "installed.", pkgs_inst) % pkgs_inst msg += " " if pkgs_upgrade > 0: msg += gettext.ngettext( "%d package is going to be upgraded.", "%d packages are going to be upgraded.", pkgs_upgrade) % pkgs_upgrade msg += " " if downloadSize > 0: msg += _("\n\nYou have to download a total of %s. ") %\ apt_pkg.SizeToStr(downloadSize) msg += estimatedDownloadTime(downloadSize) msg += "." if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100: msg += "\n\n%s" % _("Fetching and installing the upgrade can take several hours and "\ "cannot be canceled at any time later.") # Show an error if no actions are planned if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: # FIXME: this should go into DistUpgradeController summary = _("Your system is up-to-date") msg = _("There are no upgrades available for your system. " "The upgrade will now be canceled.") self.error(summary, msg) return False return self.askYesNoQuestion(summary, msg)
iter = cache["3dwm-server"] print "\nMarking '%s' for install" % iter.Name depcache.MarkInstall(iter) print "Install: %s " % depcache.InstCount print "Broken count: %s" % depcache.BrokenCount print "FixBroken() " depcache.FixBroken() print "Broken count: %s" % depcache.BrokenCount print "\nPerforming Upgrade" depcache.Upgrade() print "Keep: %s " % depcache.KeepCount print "Install: %s " % depcache.InstCount print "Delete: %s " % depcache.DelCount print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize) print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) for pkg in cache.Packages: if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \ and depcache.IsUpgradable(pkg): print "Upgrade didn't upgrade (kept): %s" % pkg.Name print "\nPerforming DistUpgrade" depcache.Upgrade(True) print "Keep: %s " % depcache.KeepCount print "Install: %s " % depcache.InstCount print "Delete: %s " % depcache.DelCount print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize) print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
def confirmChanges(self, summary, changes, demotions, downloadSize, actions=None, removal_bold=True): """ display the list of changed packages (apt.Package) and return if the user confirms them """ self.confirmChangesMessage = "" self.demotions = demotions self.toInstall = [] self.toUpgrade = [] self.toRemove = [] self.toRemoveAuto = [] self.toDowngrade = [] for pkg in changes: if pkg.marked_install: self.toInstall.append(pkg) elif pkg.marked_upgrade: self.toUpgrade.append(pkg) elif pkg.marked_delete: if pkg._pcache._depcache.is_auto_installed(pkg._pkg): self.toRemoveAuto.append(pkg) else: self.toRemove.append(pkg) elif pkg.marked_downgrade: self.toDowngrade.append(pkg) # sort it self.toInstall.sort() self.toUpgrade.sort() self.toRemove.sort() self.toRemoveAuto.sort() self.toDowngrade.sort() # no re-installs assert(len(self.toInstall)+len(self.toUpgrade)+len(self.toRemove)+len(self.toRemoveAuto)+len(self.toDowngrade) == len(changes)) # now build the message (the same for all frontends) msg = "\n" pkgs_remove = len(self.toRemove) + len(self.toRemoveAuto) pkgs_inst = len(self.toInstall) pkgs_upgrade = len(self.toUpgrade) # FIXME: show detailed packages if len(self.demotions) > 0: msg += ngettext( "%(amount)d installed package is no longer supported by Canonical. " "You can still get support from the community.", "%(amount)d installed packages are no longer supported by " "Canonical. You can still get support from the community.", len(self.demotions)) % { 'amount' : len(self.demotions) } msg += "\n\n" if pkgs_remove > 0: # FIXME: make those two separate lines to make it clear # that the "%" applies to the result of ngettext msg += ngettext("%d package is going to be removed.", "%d packages are going to be removed.", pkgs_remove) % pkgs_remove msg += " " if pkgs_inst > 0: msg += ngettext("%d new package is going to be " "installed.", "%d new packages are going to be " "installed.",pkgs_inst) % pkgs_inst msg += " " if pkgs_upgrade > 0: msg += ngettext("%d package is going to be upgraded.", "%d packages are going to be upgraded.", pkgs_upgrade) % pkgs_upgrade msg +=" " if downloadSize > 0: msg += _("\n\nYou have to download a total of %s. ") %\ apt_pkg.SizeToStr(downloadSize) msg += self.getFetchProgress().estimatedDownloadTime(downloadSize) if ((pkgs_upgrade + pkgs_inst) > 0) and ((pkgs_upgrade + pkgs_inst + pkgs_remove) > 100): if self.getFetchProgress().isDownloadSpeedEstimated(): msg += "\n\n%s" % _( "Installing the upgrade " "can take several hours. Once the download " "has finished, the process cannot be canceled.") else: msg += "\n\n%s" % _( "Fetching and installing the upgrade " "can take several hours. Once the download " "has finished, the process cannot be canceled.") else: if pkgs_remove > 100: msg += "\n\n%s" % _( "Removing the packages " "can take several hours. ") # Show an error if no actions are planned if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: # FIXME: this should go into DistUpgradeController summary = _("The software on this computer is up to date.") msg = _("There are no upgrades available for your system. " "The upgrade will now be canceled.") self.error(summary, msg) return False # set the message self.confirmChangesMessage = msg return True
#apt_pkg.Config.Set("Debug::pkgDPkgProgressReporting","1"); cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) recs = apt_pkg.GetPkgRecords(cache) list = apt_pkg.GetPkgSourceList() list.ReadMainList() # show the amount fetch needed for a dist-upgrade depcache.Upgrade(True) progress = apt.progress.TextFetchProgress() fetcher = apt_pkg.GetAcquire(progress) pm = apt_pkg.GetPackageManager(depcache) pm.GetArchives(fetcher, list, recs) print "%s (%s)" % (apt_pkg.SizeToStr(fetcher.FetchNeeded), fetcher.FetchNeeded) actiongroup = apt_pkg.GetPkgActionGroup(depcache) for pkg in cache.Packages: depcache.MarkKeep(pkg) try: os.mkdir("/tmp/pyapt-test") os.mkdir("/tmp/pyapt-test/partial") except OSError: pass apt_pkg.Config.Set("Dir::Cache::archives", "/tmp/pyapt-test") pkg = cache["3ddesktop"] depcache.MarkInstall(pkg) progress = apt.progress.TextFetchProgress()