[sulfur] inform user about orphan packages on system

This commit is contained in:
Fabio Erculiani
2010-01-09 22:01:14 +01:00
parent 50be056d6a
commit 46c48b270a
3 changed files with 75 additions and 35 deletions
+53 -16
View File
@@ -292,6 +292,7 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
self._mtime_pingus = MtimePingus()
self._spawning_ugc = False
self._preferences = None
self._orphans_message_shown = False
self.skipMirrorNow = False
self.abortQueueNow = False
self.doProgress = False
@@ -1449,6 +1450,42 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
self.ui.skipMirror.hide()
self.skipMirror = False
def add_to_queue(self, pkgs, action, always_ask):
q_cache = {}
for obj in pkgs:
q_cache[obj.matched_atom] = obj.queued
obj.queued = action
status, myaction = self.queue.add(pkgs, always_ask = always_ask)
if status != 0:
for obj in pkgs:
obj.queued = q_cache.get(obj.matched_atom)
return False
self.queueView.refresh()
self.ui.viewPkg.queue_draw()
return True
def _show_orphans_message(self, orphans):
confirm = ConfirmationDialog( self.ui.main,
orphans,
top_text = _("These packages are no longer available"),
sub_text = _("These packages should be removed because support has been dropped. Do you want to remove them?"),
bottom_text = '',
bottom_data = ''
)
result = confirm.run()
ok = False
if result == -5: # ok
ok = True
confirm.destroy()
if not ok:
return False
return self.add_to_queue(orphans, "r", False)
def show_packages(self, back_to_page = None, on_init = False):
self.ui_lock(True)
@@ -1485,7 +1522,8 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
self.start_working()
allpkgs = []
if self.doProgress: next(self.progress.total) # -> Get lists
if self.doProgress:
next(self.progress.total) # -> Get lists
self.progress.set_mainLabel(_('Generating Metadata, please wait.'))
self.progress.set_subLabel(
_('Entropy is indexing the repositories. It will take a few seconds'))
@@ -1526,6 +1564,15 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
elif allpkgs and (self.lastPkgPB != "pkgsets"):
self.ui.pkgSorter.set_property('sensitive', True)
if not self._orphans_message_shown:
if action == "updates" and empty:
orphans = self.etpbase.get_raw_groups('orphans')
if self.do_debug:
print_generic("show_packages: found orphans %s" % (orphans,))
if orphans:
self._orphans_message_shown = True
self._show_orphans_message(orphans)
self.pkgView.populate(allpkgs, empty = empty, pkgsets = show_pkgsets)
self.progress.total.show()
@@ -1543,7 +1590,10 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
self.reset_queue_progress_bars()
self.disable_ugc = False
def add_atoms_to_queue(self, atoms, always_ask = False, matches = set()):
def add_atoms_to_queue(self, atoms, always_ask = False, matches = None):
if matches is None:
matches = set()
self.set_busy()
if not matches:
@@ -1580,20 +1630,7 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
continue
found_objs.append(obj)
q_cache = {}
for obj in found_objs:
q_cache[obj.matched_atom] = obj.queued
obj.queued = "u"
status, myaction = self.queue.add(found_objs, always_ask = always_ask)
if status != 0:
rc = False
for obj in found_objs:
obj.queued = q_cache.get(obj.matched_atom)
self.queueView.refresh()
self.ui.viewPkg.queue_draw()
rc = self.add_to_queue(found_objs, "u", always_ask)
self.unset_busy()
return rc
+3 -6
View File
@@ -424,15 +424,12 @@ class SulfurApplicationEventsMixin:
pkgs = []
for idpackage, atom in atomsfound:
yp, new = self.etpbase.get_package_item((idpackage, newrepo,))
yp.action = 'i'
yp.queued = 'i'
pkgs.append(yp)
busy_cursor(self.ui.main)
status, myaction = self.queue.add(pkgs)
if status != 0:
for obj in pkgs:
obj.queued = None
done = self.add_to_queue(pkgs, "i", False)
if not done:
clean_n_quit(newrepo)
normal_cursor(self.ui.main)
return
+19 -13
View File
@@ -683,19 +683,24 @@ class EntropyPackages:
self.pkgCache[pkgdata] = yp
return yp, new
def _pkg_get_installed(self):
def __inst_pkg_setup(self, idpackage):
try:
yp, new = self.get_package_item((idpackage, 0))
except RepositoryError:
return 0
yp.action = 'r'
yp.installed_match = (idpackage, 0,)
yp.color = SulfurConf.color_install
return yp
gp_call = self.get_package_item
def fm(idpackage):
try:
yp, new = gp_call((idpackage, 0))
except RepositoryError:
return 0
yp.action = 'r'
yp.installed_match = (idpackage, 0,)
yp.color = SulfurConf.color_install
return yp
return [x for x in map(fm,
def _pkg_get_orphans(self):
updates, remove, fine, spm_fine = self.Entropy.calculate_updates(
critical_updates = False)
return [x for x in map(self.__inst_pkg_setup, remove) if not \
isinstance(x, int)]
def _pkg_get_installed(self):
return [x for x in map(self.__inst_pkg_setup,
self.Entropy.clientDbconn.listAllIdpackages(order_by = 'atom')) if \
not isinstance(x, int)]
@@ -721,7 +726,7 @@ class EntropyPackages:
def _pkg_get_updates_raw(self):
return self._pkg_get_updates(critical_updates = False)
def _pkg_get_updates(self, critical_updates = True):
def _pkg_get_updates(self, critical_updates = True, orphans = False):
gp_call = self.get_package_item
cdb_atomMatch = self.Entropy.clientDbconn.atomMatch
@@ -1022,6 +1027,7 @@ class EntropyPackages:
"queued": self._pkg_get_queued,
"available": self._pkg_get_available,
"updates": self._pkg_get_updates,
"orphans": self._pkg_get_orphans,
"unfiltered_updates": self._pkg_get_updates_raw,
"reinstallable": self._pkg_get_reinstallable,
"masked": self._pkg_get_masked,