• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python database.StoreDatabase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中softwarecenter.db.database.StoreDatabase的典型用法代码示例。如果您正苦于以下问题:Python StoreDatabase类的具体用法?Python StoreDatabase怎么用?Python StoreDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StoreDatabase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:cs2c,项目名称:AppStream,代码行数:60,代码来源:catview_gtk.py


示例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
开发者ID:cs2c,项目名称:AppStream,代码行数:28,代码来源:pkgnamesview.py


示例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)
开发者ID:pombredanne,项目名称:xmario_center,代码行数:7,代码来源:test_database.py


示例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
开发者ID:armikhael,项目名称:software-center,代码行数:60,代码来源:apptreeview.py


示例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"]
开发者ID:cs2c,项目名称:AppStream,代码行数:29,代码来源:test_database.py


示例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
开发者ID:fossasia,项目名称:x-mario-center,代码行数:30,代码来源:catview_gtk.py


示例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")
开发者ID:cs2c,项目名称:AppStream,代码行数:25,代码来源:test_reinstall_purchased.py


示例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)
开发者ID:armikhael,项目名称:software-center,代码行数:33,代码来源:test_database.py


示例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)
开发者ID:armikhael,项目名称:software-center,代码行数:7,代码来源:test_database.py


示例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))
开发者ID:mortenpi,项目名称:ubuntu-software-center,代码行数:34,代码来源:test_database.py


示例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
开发者ID:armikhael,项目名称:software-center,代码行数:9,代码来源:testutils.py


示例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)
开发者ID:pombredanne,项目名称:AppStream,代码行数:12,代码来源:test_mime.py


示例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()
开发者ID:pombredanne,项目名称:shop,代码行数:13,代码来源:categoriesmodel.py


示例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)
开发者ID:armikhael,项目名称:software-center,代码行数:14,代码来源:test_database.py


示例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()
开发者ID:pombredanne,项目名称:xmario_center,代码行数:7,代码来源:test_where_is_it.py


示例16: _get_apps_for_category

 def _get_apps_for_category(self, category):
     query = get_query_for_category(self.db, category)
     if not query:
         LOG.warn("_get_apps_for_category: received invalid category")
         return []
     
     pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
     db = StoreDatabase(pathname, self.cache)
     db.open()
     docs = db.get_docs_from_query(query)
     
     #from the db docs, return a list of pkgnames
     applist = []
     for doc in docs:
         applist.append(db.get_pkgname(doc))
     return applist
开发者ID:cs2c,项目名称:AppStream,代码行数:16,代码来源:__init__.py


示例17: test_non_axi_apps_cataloged_time

    def test_non_axi_apps_cataloged_time(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=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)
        so_app = Application("Scintillant Orange", "scintillant-orange")
        so_doc = db.get_xapian_document(so_app.appname, so_app.pkgname)
        so_cataloged_time = so_doc.get_value(axi_value_time)
        # the test package Scintillant Orange should be cataloged at a
        # later time than axi package Ubuntu Software Center
        self.assertTrue(so_cataloged_time > sc_cataloged_time)
开发者ID:armikhael,项目名称:software-center,代码行数:18,代码来源:test_database.py


示例18: 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()
     self.catview = CategoriesParser(self.db)
     self.catview.db = self.db
     self.cats = self.catview.parse_applications_menu('/usr/share/app-install')
开发者ID:armikhael,项目名称:software-center,代码行数:10,代码来源:test_cat_parsing.py


示例19: 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), "hellox")
         self.assertEqual(doc.get_value(XapianValues.ARCHIVE_SIGNING_KEY_ID), "1024R/0EB12F05")
         self.assertEqual(doc.get_value(XapianValues.ARCHIVE_DEB_LINE),
                                        "deb https://username:[email protected]/mvo/private-test/ubuntu maverick main #Personal access of username to private-test")
         break # only one match
开发者ID:armikhael,项目名称:software-center,代码行数:22,代码来源:test_reinstall_purchased.py


示例20: TestCatParsing

class TestCatParsing(unittest.TestCase):
    """ tests the "where is it in the menu" code """

    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()
        self.catview = CategoriesParser(self.db)
        self.catview.db = self.db
        self.cats = self.catview.parse_applications_menu('/usr/share/app-install')

    def test_get_cat_by_name(self):
        cat = get_category_by_name(self.cats, 'Games')
        self.assertEqual(cat.untranslated_name, 'Games')
        cat = get_category_by_name(self.cats, 'Featured')
        self.assertEqual(cat.untranslated_name, 'Featured')

    def test_cat_has_flags(self):
        cat = get_category_by_name(self.cats, 'Featured')
        self.assertEqual(cat.flags[0], 'carousel-only')
开发者ID:armikhael,项目名称:software-center,代码行数:23,代码来源:test_cat_parsing.py



注:本文中的softwarecenter.db.database.StoreDatabase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python enquire.AppEnquire类代码示例发布时间:2022-05-27
下一篇:
Python application.Application类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap