def setUp(self): # FIXME: create a fixture DB instead of using the system one # but for now that does not matter that much, only if we # call open the db is actually read and the path checked pathname = "../data/xapian" if not os.listdir(pathname): rebuild_database(pathname) self.xapiandb = xapian.Database(pathname) self.enquire = xapian.Enquire(self.xapiandb)
def setUp(self): # FIXME: create a fixture DB instead of using the system one # but for now that does not matter that much, only if we # call open the db is actually read and the path checked pathname = os.path.join(REAL_DATA_DIR, "xapian") if not os.path.exists(pathname): os.makedirs(pathname) if not os.listdir(pathname): rebuild_database(pathname) self.xapiandb = xapian.Database(pathname) self.enquire = xapian.Enquire(self.xapiandb)
def test_most_popular_applications_for_mimetype(self): pathname = "../data/xapian" if not os.listdir(pathname): rebuild_database(pathname) db = StoreDatabase(pathname, self.cache) db.open() # all result = db.get_most_popular_applications_for_mimetype("text/html", only_uninstalled=False, num=5) self.assertEqual(len(result), 5) # only_uninstaleld result = db.get_most_popular_applications_for_mimetype("text/html", only_uninstalled=True, num=2) self.assertEqual(len(result), 2)
def test_most_popular_applications_for_mimetype(self): pathname = os.path.join(REAL_DATA_DIR, "xapian") if not os.listdir(pathname): rebuild_database(pathname) db = StoreDatabase(pathname, self.cache) db.open() # all result = db.get_most_popular_applications_for_mimetype("text/html", only_uninstalled=False, num=5) self.assertEqual(len(result), 5) # only_uninstaleld result = db.get_most_popular_applications_for_mimetype("text/html", only_uninstalled=True, num=2) self.assertEqual(len(result), 2)
from softwarecenter.paths import XAPIAN_BASE_PATH from softwarecenter.db.database import StoreDatabase xapian_base_path = XAPIAN_BASE_PATH pathname = os.path.join(xapian_base_path, "xapian") try: db = StoreDatabase(pathname, cache) db.open() except xapian.DatabaseOpeningError: # Couldn't use that folder as a database # This may be because we are in a bzr checkout and that # folder is empty. If the folder is empty, and we can find the # script that does population, populate a database in it. if os.path.isdir(pathname) and not os.listdir(pathname): from softwarecenter.db.update import rebuild_database logging.info("building local database") rebuild_database(pathname) db = StoreDatabase(pathname, cache) db.open() except xapian.DatabaseCorruptError as e: logging.exception("xapian open failed") dialogs.error(None, _("Sorry, can not open the software database"), _("Please re-install the 'software-center' " "package.")) # FIXME: force rebuild by providing a dbus service for this sys.exit(1) purchased_packages = set() purchased_packages.add('file-roller') purchased_packages.add('alarm-clock') purchased_packages.add('pitivi') purchased_packages.add('chromium-browser')
from softwarecenter.paths import XAPIAN_BASE_PATH from softwarecenter.db.database import StoreDatabase xapian_base_path = XAPIAN_BASE_PATH pathname = os.path.join(xapian_base_path, "xapian") try: db = StoreDatabase(pathname, cache) db.open() except xapian.DatabaseOpeningError: # Couldn't use that folder as a database # This may be because we are in a bzr checkout and that # folder is empty. If the folder is empty, and we can find the # script that does population, populate a database in it. if os.path.isdir(pathname) and not os.listdir(pathname): from softwarecenter.db.update import rebuild_database logging.info("building local database") rebuild_database(pathname) db = StoreDatabase(pathname, cache) db.open() except xapian.DatabaseCorruptError as e: logging.exception("xapian open failed") dialogs.error(None, _("Sorry, can not open the software database"), _("Please re-install the 'software-center' " "package.")) # FIXME: force rebuild by providing a dbus service for this sys.exit(1) purchased_packages = set() purchased_packages.add('file-roller') purchased_packages.add('alarm-clock') purchased_packages.add('pitivi')