39
39
from softwarecenter.ui.gtk3.views.appview import AppViewFilter
40
40
import softwarecenter.ui.gtk3.dialogs as dialogs
42
LOG=logging.getLogger(__name__)
42
44
def interrupt_build_and_wait(f):
43
45
""" decorator that ensures that a build of the categorised installed apps
44
46
is interrupted before a new build commences.
47
49
def wrapper(*args, **kwargs):
49
51
if self._build_in_progress:
50
print 'Waiting for build to exit...'
52
LOG.debug('Waiting for build to exit...')
51
53
self._halt_build = True
52
54
GObject.timeout_add(200, lambda: wrapper(*args, **kwargs))
187
189
# node to tree_view
188
190
if not self._use_category(cat): continue
189
191
query = self.get_query_for_cat(cat)
192
LOG.debug("filter.instaleld_only: %s" % self.state.filter.installed_only)
190
193
enq.set_query(query,
191
194
sortmode=SortMethods.BY_ALPHABET,
192
195
nonapps_visible=self.nonapps_visible,
278
281
self.state.search_term)
280
283
def get_query_for_cat(self, cat):
281
#~ print self.state.channel
284
LOG.debug("self.state.channel: %s" % self.state.channel)
282
285
if self.state.channel and self.state.channel.query:
283
286
query = xapian.Query(xapian.Query.OP_AND,
384
387
length) % { 'amount' : length, }
386
389
def display_overview_page(self, page, view_state):
390
LOG.debug("view_state: %s" % view_state)
387
391
self._build_categorised_view()
389
393
if self.state.search_term:
424
428
if __name__ == "__main__":
426
from softwarecenter.paths import XAPIAN_BASE_PATH
427
from softwarecenter.db.database import StoreDatabase
429
#logging.basicConfig(level=logging.DEBUG)
431
if len(sys.argv) > 1:
432
datadir = sys.argv[1]
433
elif os.path.exists("./data"):
436
datadir = "/usr/share/software-center"
438
from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
439
icons = get_sc_icon_theme(datadir)
441
Gtk.Window.set_default_icon_name("softwarecenter")
443
from softwarecenter.db.pkginfo import get_pkg_info
444
cache = get_pkg_info()
448
xapian_base_path = XAPIAN_BASE_PATH
449
pathname = os.path.join(xapian_base_path, "xapian")
451
db = StoreDatabase(pathname, cache)
453
except xapian.DatabaseOpeningError:
454
# Couldn't use that folder as a database
455
# This may be because we are in a bzr checkout and that
456
# folder is empty. If the folder is empty, and we can find the
457
# script that does population, populate a database in it.
458
if os.path.isdir(pathname) and not os.listdir(pathname):
459
from softwarecenter.db.update import rebuild_database
460
logging.info("building local database")
461
rebuild_database(pathname)
462
db = StoreDatabase(pathname, cache)
464
except xapian.DatabaseCorruptError, e:
465
logging.exception("xapian open failed")
467
_("Sorry, can not open the software database"),
468
_("Please re-install the 'software-center' "
470
# FIXME: force rebuild by providing a dbus service for this
430
from softwarecenter.testutils import (get_test_db,
432
get_test_gtk3_viewmanager,
436
# needed because available pane will try to get it
437
vm = get_test_gtk3_viewmanager()
438
vm # make pyflakes happy
440
cache = get_test_pkg_info()
441
datadir = get_test_datadir()
442
icons = get_test_icon_cache()
473
444
w = InstalledPane(cache, db, 'Ubuntu', icons, datadir)