Don't break menu if apt fails to initialize

This commit is contained in:
Clement Lefebvre 2010-09-10 13:34:44 +01:00
parent 022aed6b83
commit 18e9c6616a
2 changed files with 35 additions and 15 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
mintmenu (5.0.4) julia; urgency=low
* Don't break menu if apt fails to initialize
-- Clement Lefebvre <root@linuxmint.com> Fri, 10 Sep 2010 13:34:00 +0000
mintmenu (5.0.3) julia; urgency=low
* Fixed separators colors in search results

View File

@ -221,7 +221,12 @@ class pluginclass( object ):
@print_timing
def __init__( self, mintMenuWin, toggleButton ):
self.apt_cache = None
try:
self.apt_cache = apt.Cache()
except Exception, detail:
print "Could not initialize APT cache"
pass
self.mintMenuWin = mintMenuWin
@ -457,6 +462,14 @@ class pluginclass( object ):
self.favoritesPositionOnGrid( fav )
def RegenPlugin( self, *args, **kargs ):
try:
apt_cache = apt.Cache()
if apt_cache != None:
self.apt_cache = apt_cache
except Exception, detail:
print "Could not refresh APT cache"
pass
# save old config - this is necessary because the app will notified when it sets the default values and you don't want the to reload itself several times
oldcategories_mouse_over = self.categories_mouse_over
oldtotalrecent = self.totalrecent
@ -690,6 +703,7 @@ class pluginclass( object ):
self.current_results = []
self.add_search_suggestions(text)
found_packages = 0
if self.apt_cache is not None:
for pkg in self.apt_cache:
if text in pkg.name:
found_packages+=1