def plan_remove_item(self, item, automatic=False): """ Plan removal of a given item """ trans = Transaction(item) if not automatic: (pg, pkgs) = plan_remove([item.get_id()]) else: (pg, pkgs) = plan_autoremove([item.get_id()]) for name in pkgs: trans.push_removal(self.build_item(name)) return trans
def plan_remove_item(self, item, automatic=False): """ Plan removal of a given item """ trans = Transaction(item) if not automatic: (pg, pkgs) = plan_remove([item.get_id()]) else: (pg, pkgs) = plan_autoremove([item.get_id()]) for name in pkgs: trans.push_removal(self.build_item(name)) return trans
def apply_operations(self): self.doing_things = True updates = [ i for i in self.operations if self.operations[i] == 'UPDATE' ] installs = [ i for i in self.operations if self.operations[i] == 'INSTALL' ] removals = [ i for i in self.operations if self.operations[i] == 'UNINSTALL' ] # We monitor 4 post events STEPS = 4 self.installdb = pisi.db.installdb.InstallDB() self.packagedb = pisi.db.packagedb.PackageDB() self.emit('basket-changed', None) # print "%d packages updated" % len(updates) # print "%d packages installed" % len(installs) # print "%d packages removed" % len(removals) setAct = False for packageset in [updates, installs, removals]: if len(packageset) == 0: continue self.current_package = 1 self.current_dl_package = 1 if packageset == installs: (pg, pkgs) = plan_install_pkg_names(packageset) if len(pkgs) > len(packageset): p = [x for x in pkgs if x not in packageset] if self.show_dialog(p): installs = packageset = pkgs else: # print "Not installing" continue elif packageset == removals: (pk, pkgs) = plan_remove(packageset) if len(pkgs) > len(packageset): p = [x for x in pkgs if x not in packageset] if self.show_dialog(p, remove=True): removals = packageset = pkgs else: # print "Not removing" continue elif packageset == updates: (pk, pkgs) = plan_upgrade(packageset) if len(pkgs) > len(packageset): p = [x for x in pkgs if x not in packageset] if self.show_dialog(p, update=True): updates = packageset = pkgs else: # print Not continuing continue self.total_packages = len(packageset) setAct = True if packageset != removals: self.total_size = self.get_sizes(packageset) # one tenth of progress is post install self.step_offset = self.total_size / 10 self.progress_total = self.total_size + \ ((self.step_offset * self.total_packages) * STEPS) else: self.total_size = self.total_packages * (STEPS / 2) self.step_offset = 1 self.progress_total = self.total_size self.progress_current = 0 self.current_operations = packageset self.cb = self.invalidate_all if packageset == updates: self.pmanager.updatePackage(",".join(packageset), async=self.pisi_callback) elif packageset == installs: self.pmanager.installPackage(",".join(packageset), async=self.pisi_callback) elif packageset == removals: self.pmanager.removePackage(",".join(packageset), async=self.pisi_callback) if not setAct: self.invalidate_all() self.update_ui()
def apply_operations(self): self.doing_things = True updates = [ i for i in self.operations if self.operations[i] == 'UPDATE' ] installs = [ i for i in self.operations if self.operations[i] == 'INSTALL' ] removals = [ i for i in self.operations if self.operations[i] == 'UNINSTALL' ] # We monitor 4 post events STEPS = 4 self.installdb = pisi.db.installdb.InstallDB() self.packagedb = pisi.db.packagedb.PackageDB() self.emit('apply', None) # print "%d packages updated" % len(updates) # print "%d packages installed" % len(installs) # print "%d packages removed" % len(removals) setAct = False for packageset in [updates, installs, removals]: if len(packageset) == 0: continue self.current_package = 1 self.current_dl_package = 1 if packageset == installs: (pg, pkgs) = plan_install_pkg_names(packageset) if len(pkgs) > len(packageset): p = [x for x in pkgs if x not in packageset] if self.show_dialog(p): installs = packageset = pkgs else: # print "Not installing" continue elif packageset == removals: (pk, pkgs) = plan_remove(packageset) if len(pkgs) > len(packageset): p = [x for x in pkgs if x not in packageset] if self.show_dialog(p, remove=True): removals = packageset = pkgs else: # print "Not removing" continue elif packageset == updates: (pk, pkgs) = plan_upgrade(packageset) if len(pkgs) > len(packageset): p = [x for x in pkgs if x not in packageset] if self.show_dialog(p, update=True): updates = packageset = pkgs else: # print Not continuing continue self.total_packages = len(packageset) setAct = True if packageset != removals: self.total_size = self.get_sizes(packageset) # one tenth of progress is post install self.step_offset = self.total_size / 10 self.progress_total = self.total_size + \ ((self.step_offset * self.total_packages) * STEPS) else: self.total_size = self.total_packages * (STEPS / 2) self.step_offset = 1 self.progress_total = self.total_size self.progress_current = 0 self.current_operations = packageset self.cb = self.invalidate_all if packageset == updates: self.pmanager.updatePackage( ",".join(packageset), async=self.pisi_callback) elif packageset == installs: self.pmanager.installPackage( ",".join(packageset), async=self.pisi_callback) elif packageset == removals: self.pmanager.removePackage( ",".join(packageset), async=self.pisi_callback) if not setAct: self.invalidate_all() self.update_ui()