本文整理汇总了Python中softwarecenter.db.database.StoreDatabase类的典型用法代码示例。如果您正苦于以下问题:Python StoreDatabase类的具体用法?Python StoreDatabase怎么用?Python StoreDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StoreDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_test_window_catview
def get_test_window_catview():
def on_category_selected(view, cat):
print("on_category_selected %s %s" % view, cat)
cache = get_pkg_info()
cache.open()
from softwarecenter.db.database import StoreDatabase
xapian_base_path = "/var/cache/software-center"
pathname = os.path.join(xapian_base_path, "xapian")
db = StoreDatabase(pathname, cache)
db.open()
import softwarecenter.paths
datadir = softwarecenter.paths.datadir
from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
icons = get_sc_icon_theme(datadir)
import softwarecenter.distro
distro = softwarecenter.distro.get_distro()
apps_filter = AppFilter(db, cache)
# gui
win = Gtk.Window()
n = Gtk.Notebook()
from softwarecenter.paths import APP_INSTALL_PATH
view = LobbyViewGtk(datadir, APP_INSTALL_PATH,
cache, db, icons, distro, apps_filter)
win.set_data("lobby", view)
scroll = Gtk.ScrolledWindow()
scroll.add(view)
n.append_page(scroll, Gtk.Label(label="Lobby"))
# find a cat in the LobbyView that has subcategories
subcat_cat = None
for cat in reversed(view.categories):
if cat.subcategories:
subcat_cat = cat
break
view = SubCategoryViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons,
apps_filter)
view.connect("category-selected", on_category_selected)
view.set_subcategory(subcat_cat)
win.set_data("subcat", view)
scroll = Gtk.ScrolledWindow()
scroll.add(view)
n.append_page(scroll, Gtk.Label(label="Subcats"))
win.add(n)
win.set_size_request(800, 800)
win.show_all()
win.connect('destroy', Gtk.main_quit)
return win
示例2: get_test_window_pkgnamesview
def get_test_window_pkgnamesview():
from softwarecenter.db.pkginfo import get_pkg_info
cache = get_pkg_info()
cache.open()
from softwarecenter.db.database import StoreDatabase
xapian_base_path = "/var/cache/software-center"
pathname = os.path.join(xapian_base_path, "xapian")
db = StoreDatabase(pathname, cache)
db.open()
import softwarecenter.paths
datadir = softwarecenter.paths.datadir
from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
icons = get_sc_icon_theme(datadir)
pkgs = ["apt", "software-center"]
view = PackageNamesView("header", cache, pkgs, icons, 32, db)
view.show()
win = Gtk.Window()
win.add(view)
win.set_size_request(600, 400)
win.show()
win.connect('destroy', Gtk.main_quit)
return win
示例3: test_app_enquire
def test_app_enquire(self):
db = StoreDatabase(cache=self.cache)
db.open()
# test the AppEnquire engine
enquirer = AppEnquire(self.cache, db)
enquirer.set_query(xapian.Query("a"), nonblocking_load=False)
self.assertTrue(len(enquirer.get_docids()) > 0)
示例4: get_test_window
def get_test_window():
import softwarecenter.log
softwarecenter.log.root.setLevel(level=logging.DEBUG)
softwarecenter.log.add_filters_from_string("performance")
fmt = logging.Formatter("%(name)s - %(message)s", None)
softwarecenter.log.handler.setFormatter(fmt)
from softwarecenter.paths import XAPIAN_BASE_PATH
xapian_base_path = XAPIAN_BASE_PATH
pathname = os.path.join(xapian_base_path, "xapian")
# the store
from softwarecenter.db.pkginfo import get_pkg_info
cache = get_pkg_info()
cache.open()
# the db
from softwarecenter.db.database import StoreDatabase
db = StoreDatabase(pathname, cache)
db.open()
# additional icons come from app-install-data
icons = Gtk.IconTheme.get_default()
icons.prepend_search_path("/usr/share/app-install/icons/")
icons.prepend_search_path("/usr/share/software-center/icons/")
# create a filter
from softwarecenter.db.appfilter import AppFilter
filter = AppFilter(db, cache)
filter.set_supported_only(False)
filter.set_installed_only(True)
# appview
from softwarecenter.ui.gtk3.models.appstore2 import AppListStore
from softwarecenter.db.enquire import AppEnquire
enquirer = AppEnquire(cache, db)
store = AppListStore(db, cache, icons)
from softwarecenter.ui.gtk3.views.appview import AppView
view = AppView(db, cache, icons, show_ratings=True)
view.set_model(store)
entry = Gtk.Entry()
entry.stamp = 0
entry.connect("changed", on_entry_changed, (view, enquirer))
entry.set_text("gtk3")
scroll = Gtk.ScrolledWindow()
box = Gtk.VBox()
box.pack_start(entry, False, True, 0)
box.pack_start(scroll, True, True, 0)
win = Gtk.Window()
win.connect("destroy", lambda x: Gtk.main_quit())
scroll.add(view)
win.add(box)
win.set_size_request(600, 400)
win.show_all()
return win
示例5: disabled_test_for_purchase_apps_cataloged_time
def disabled_test_for_purchase_apps_cataloged_time(self):
from softwarecenter.testutils import get_test_pkg_info
#os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
# staging does not have a valid cert
os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
cache = get_test_pkg_info()
db = xapian.WritableDatabase("./data/test.db",
xapian.DB_CREATE_OR_OVERWRITE)
res = update_from_software_center_agent(db, cache, ignore_cache=True)
self.assertTrue(res)
res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
self.assertTrue(res)
db = StoreDatabase("./data/test.db", self.cache)
db.open(use_axi=True)
axi_value_time = db._axi_values["catalogedtime"]
sc_app = Application("Ubuntu Software Center Test", "software-center")
sc_doc = db.get_xapian_document(sc_app.appname, sc_app.pkgname)
sc_cataloged_time = sc_doc.get_value(axi_value_time)
for_purch_app = Application("For Purchase Test App", "hellox")
for_purch_doc = db.get_xapian_document(for_purch_app.appname,
for_purch_app.pkgname)
for_purch_cataloged_time = for_purch_doc.get_value(axi_value_time)
# the for-purchase test package should be cataloged at a
# later time than axi package Ubuntu Software Center
self.assertTrue(for_purch_cataloged_time > sc_cataloged_time)
del os.environ["SOFTWARE_CENTER_AGENT_HOST"]
示例6: get_test_catview
def get_test_catview():
def on_category_selected(view, cat):
print("on_category_selected %s %s" % view, cat)
from softwarecenter.db.pkginfo import get_pkg_info
cache = get_pkg_info()
cache.open()
from softwarecenter.db.database import StoreDatabase
xapian_base_path = "/var/cache/software-center"
pathname = os.path.join(xapian_base_path, "xapian")
db = StoreDatabase(pathname, cache)
db.open()
import softwarecenter.paths
datadir = softwarecenter.paths.datadir
from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
icons = get_sc_icon_theme(datadir)
import softwarecenter.distro
distro = softwarecenter.distro.get_distro()
apps_filter = AppFilter(db, cache)
from softwarecenter.paths import APP_INSTALL_PATH
cat_view = LobbyViewGtk(datadir, APP_INSTALL_PATH,
cache, db, icons, distro, apps_filter)
return cat_view
示例7: test_reinstall_purchased_xapian
def test_reinstall_purchased_xapian(self):
db = StoreDatabase("/var/cache/software-center/xapian", self.cache)
db.open(use_axi=False)
# now create purchased debs xapian index (in memory because
# we store the repository passwords in here)
old_db_len = len(db)
query = add_from_purchased_but_needs_reinstall_data(
self.available_to_me, db, self.cache)
# ensure we have a new item (the available for reinstall one)
self.assertEqual(len(db), old_db_len+1)
# query
enquire = xapian.Enquire(db.xapiandb)
enquire.set_query(query)
matches = enquire.get_mset(0, len(db))
self.assertEqual(len(matches), 1)
for m in matches:
doc = db.xapiandb.get_document(m.docid)
self.assertEqual(doc.get_value(XapianValues.PKGNAME), "photobomb")
self.assertEqual(
doc.get_value(XapianValues.ARCHIVE_SIGNING_KEY_ID),
"1024R/75254D99")
self.assertEqual(doc.get_value(XapianValues.ARCHIVE_DEB_LINE),
"deb https://username:[email protected]"
"private-ppa.launchpad.net/commercial-ppa-uploaders"
"/photobomb/ubuntu natty main")
示例8: test_package_states
def test_package_states(self):
db = xapian.WritableDatabase("./data/test.db",
xapian.DB_CREATE_OR_OVERWRITE)
res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
self.assertTrue(res)
db = StoreDatabase("./data/test.db", self.cache)
db.open(use_axi=False)
# test PkgStates.INSTALLED
# FIXME: this will only work if software-center is installed
app = Application("Ubuntu Software Center Test", "software-center")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
# test PkgStates.UNINSTALLED
# test PkgStates.UPGRADABLE
# test PkgStates.REINSTALLABLE
# test PkgStates.INSTALLING
# test PkgStates.REMOVING
# test PkgStates.UPGRADING
# test PkgStates.NEEDS_SOURCE
app = Application("Zynjacku Test", "zynjacku-fake")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_SOURCE)
# test PkgStates.NEEDS_PURCHASE
app = Application("The expensive gem", "expensive-gem")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_PURCHASE)
self.assertEqual(appdetails.icon_url, "http://www.google.com/favicon.ico")
self.assertEqual(appdetails.icon, "favicon")
# test PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED
# test PkgStates.UNKNOWN
app = Application("Scintillant Orange", "scintillant-orange")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.NOT_FOUND)
示例9: test_packagename_is_application
def test_packagename_is_application(self):
db = StoreDatabase("/var/cache/software-center/xapian", self.cache)
db.open()
# apt has no app
self.assertEqual(db.get_apps_for_pkgname("apt"), set())
# but software-center has
self.assertEqual(len(db.get_apps_for_pkgname("software-center")), 1)
示例10: test_package_states
def test_package_states(self):
db = xapian.WritableDatabase(TEST_DB, xapian.DB_CREATE_OR_OVERWRITE)
res = update_from_app_install_data(db, self.cache, datadir=os.path.join(DATA_DIR, "desktop"))
self.assertTrue(res)
db = StoreDatabase(TEST_DB, self.cache)
db.open(use_axi=False)
# test PkgStates.INSTALLED
# FIXME: this will only work if software-center is installed
app = Application("Ubuntu Software Center Test", "software-center")
appdetails = app.get_details(db)
self.assertTrue(appdetails.pkg_state in (PkgStates.INSTALLED, PkgStates.UPGRADABLE))
# test PkgStates.UNINSTALLED
# test PkgStates.UPGRADABLE
# test PkgStates.REINSTALLABLE
# test PkgStates.INSTALLING
# test PkgStates.REMOVING
# test PkgStates.UPGRADING
# test PkgStates.NEEDS_SOURCE
app = Application("Zynjacku Test", "zynjacku-fake")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_SOURCE)
# test PkgStates.NEEDS_PURCHASE
app = Application("The expensive gem", "expensive-gem")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_PURCHASE)
self.assertEqual(appdetails.icon_url, "http://www.google.com/favicon.ico")
self.assertEqual(appdetails.icon, "expensive-gem-icon-favicon")
# test PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED
# test PkgStates.UNKNOWN
app = Application("Scintillant Orange", "scintillant-orange")
appdetails = app.get_details(db)
self.assertEqual(appdetails.pkg_state, PkgStates.NOT_FOUND)
expected = ["use::converting", "role::program", "implemented-in::perl"]
self.assertEqual(appdetails.tags, set(expected))
示例11: get_test_db
def get_test_db():
from softwarecenter.db.database import StoreDatabase
from softwarecenter.db.pkginfo import get_pkg_info
import softwarecenter.paths
cache = get_pkg_info()
cache.open()
db = StoreDatabase(softwarecenter.paths.XAPIAN_PATH, cache)
db.open()
return db
示例12: test_most_popular_applications_for_mimetype
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)
示例13: __init__
def __init__(self, parent=None):
super(CategoriesModel, self).__init__()
self._categories = []
roles = dict(enumerate(CategoriesModel.COLUMNS))
self.setRoleNames(roles)
pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
# FIXME: move this into app
cache = get_pkg_info()
db = StoreDatabase(pathname, cache)
db.open()
# /FIXME
self.catparser = CategoriesParser(db)
self._categories = self.catparser.parse_applications_menu()
示例14: test_whats_new
def test_whats_new(self):
db = StoreDatabase("/var/cache/software-center/xapian", self.cache)
db.open()
query = xapian.Query("")
enquire = xapian.Enquire(db.xapiandb)
enquire.set_query(query)
value_time = db._axi_values["catalogedtime"]
enquire.set_sort_by_value(value_time, reverse=True)
matches = enquire.get_mset(0, 20)
last_time = 0
for m in matches:
doc = m.document
doc.get_value(value_time) >= last_time
last_time = doc.get_value(value_time)
示例15: setUp
def setUp(self):
cache = get_pkg_info()
cache.open()
xapian_base_path = XAPIAN_BASE_PATH
pathname = os.path.join(xapian_base_path, "xapian")
self.db = StoreDatabase(pathname, cache)
self.db.open()