def toggle_from_items(self, items): self.setBusy(True) actiongroup = apt_pkg.ActionGroup(self.cache._depcache) # Deselect all updates if any are selected keep_packages = any([item.is_selected() for item in items]) for item in items: try: if keep_packages: item.pkg.mark_keep() elif item.pkg.name not in self.list.held_back: if not item.to_remove: item.pkg.mark_install() else: item.pkg.mark_delete() except SystemError: pass # check if we left breakage if self.cache._depcache.broken_count: Fix = apt_pkg.ProblemResolver(self.cache._depcache) Fix.resolve_by_keep() self.updates_changed() self.treeview_update.queue_draw() del actiongroup self.setBusy(False)
def openCache(self): # open cache progress = apt.progress.text.OpProgress() if hasattr(self, "cache"): self.cache.open(progress) self.cache._initDepCache() else: self.cache = MyCache(progress) self.actiongroup = apt_pkg.ActionGroup(self.cache._depcache) # lock the cache self.cache.lock = True
def actiongroup(self): """Return an `ActionGroup` object for the current cache. Action groups can be used to speedup actions. The action group is active as soon as it is created, and disabled when the object is deleted or when release() is called. You can use the action group as a context manager, this is the recommended way:: with cache.actiongroup(): for package in my_selected_packages: package.mark_install() This way, the action group is automatically released as soon as the with statement block is left. It also has the benefit of making it clear which parts of the code run with a action group and which don't. """ return apt_pkg.ActionGroup(self._depcache)
def _satisfy_depends(self, depends): """Satisfy the dependencies.""" # turn off MarkAndSweep via a action group (if available) try: _actiongroup = apt_pkg.ActionGroup(self._cache._depcache) _actiongroup # pyflakes except AttributeError: pass # check depends for or_group in depends: if not self._is_or_group_satisfied(or_group): if not self._satisfy_or_group(or_group): return False # now try it out in the cache for pkg in self._need_pkgs: try: self._cache[pkg].mark_install(from_user=False) except SystemError: self._failure_string = _("Cannot install '%s'") % pkg self._cache.clear() return False return True
def refresh_system_call(self): '''Call the refresh of the app''' apt_pkg.init() self.cache = apt_pkg.Cache() if self.action_group is not None: self.action_group.release() self.depcache = apt_pkg.DepCache(self.cache) self.action_group = apt_pkg.ActionGroup(self.depcache) control.__init__() self.aid = control.controller.app_install_directory self.marked_as_install = [] self.theme = Gtk.IconTheme.get_default() self.theme.append_search_path("/usr/share/app-install/icons/") self.current_apps_model = self.ui.apps_all.model self.current_installed_model = self.ui.apps_installed.model self.refresh_app_basket() self.ui.apps_all.set_model(self.ui.apps_all.model) self.ui.apps_installed.set_model(self.ui.apps_installed.model) self.ui.apps_message.set_visible(False) self.ui.installed_message.set_visible(False) if self.ui.toolbar.__class__.__name__ == "Toolbar": self.ui.toolbar.set_style(3) self.packages = [] if (not self.startup) and (self.ui.pages.get_page() in [1, 2]): if self.ui.pages.get_page() == 1: self.get_func() if self.choosed_category == "fonts": showboth = True else: showboth = False self.append_packages_call(self.choosed_category, [], self.ui.apps_all.model, showboth) if self.ui.pages.get_page() == 2: self.installed_func() elif self.startup: self.back_home(None) if control.controller.check_internet: self.check_internet() self.startup = False
except: dist_upgrade = True if dist_upgrade: selection = sys.argv[1:] #print ' '.join(str(pkg) for pkg in selection) packages_to_install = [] packages_to_remove = [] apt_pkg.init() cache = apt_pkg.Cache(None) depcache = apt_pkg.DepCache(cache) depcache.Init() with apt_pkg.ActionGroup(depcache): for package in selection: pkg = cache[package] #print "Marking : %s to install" % pkg.Name depcache.mark_install(pkg) #print "Install : %d" % depcache.inst_count #print "Remove : %d" % depcache.del_count # Get changes for pkg in cache.packages: if not depcache.marked_keep(pkg): if depcache.marked_install(pkg) or depcache.marked_upgrade( pkg): if not pkg.Name in selection: if not '%s:%s' % (pkg.Name,
cache = apt_pkg.Cache() depcache = apt_pkg.DepCache(cache) recs = apt_pkg.PackageRecords(cache) list = apt_pkg.SourceList() list.read_main_list() # show the amount fetch needed for a dist-upgrade depcache.upgrade(True) progress = apt.progress.text.AcquireProgress() fetcher = apt_pkg.Acquire(progress) pm = apt_pkg.PackageManager(depcache) pm.get_archives(fetcher, list, recs) print "%s (%s)" % (apt_pkg.size_to_str( fetcher.fetch_needed), fetcher.fetch_needed) actiongroup = apt_pkg.ActionGroup(depcache) for pkg in cache.packages: depcache.mark_keep(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.mark_install(pkg) progress = apt.progress.text.AcquireProgress() fetcher = apt_pkg.Acquire(progress)