當前位置: 首頁>>代碼示例>>Python>>正文


Python Application.get_details方法代碼示例

本文整理匯總了Python中softwarecenter.db.application.Application.get_details方法的典型用法代碼示例。如果您正苦於以下問題:Python Application.get_details方法的具體用法?Python Application.get_details怎麽用?Python Application.get_details使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在softwarecenter.db.application.Application的用法示例。


在下文中一共展示了Application.get_details方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_package_states

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 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,代碼行數:36,代碼來源:test_database.py

示例2: test_package_states

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 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,代碼行數:35,代碼來源:test_database.py

示例3: get_most_popular_applications_for_mimetype

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def get_most_popular_applications_for_mimetype(self, mimetype, 
                                               only_uninstalled=True, num=3):
     """ return a list of the most popular applications for the given
         mimetype 
     """
     # sort by popularity by default
     enquire = xapian.Enquire(self.xapiandb)
     enquire.set_sort_by_value_then_relevance(XapianValues.POPCON)
     # query mimetype
     query = xapian.Query("AM%s"%mimetype)
     enquire.set_query(query)
     # mset just needs to be "big enough""
     matches = enquire.get_mset(0, 100)
     apps = []
     for match in matches:
         doc = match.document
         app = Application(self.get_appname(doc),self.get_pkgname(doc),
                           popcon=self.get_popcon(doc))
         if only_uninstalled:
             if app.get_details(self).pkg_state == PkgStates.UNINSTALLED:
                 apps.append(app)
         else:
             apps.append(app)
         if len(apps) == num:
             break
     return apps
開發者ID:Alberto-Beralix,項目名稱:Beralix,代碼行數:28,代碼來源:database.py

示例4: test_not_automatic_version

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_not_automatic_version(self):
     db = get_test_db()
     app = Application("", "software-center")
     details = app.get_details(db)
     normal_version = self._make_version(not_automatic=False)
     not_automatic_version = self._make_version(not_automatic=True)
     details._pkg.versions = [normal_version, not_automatic_version]
     # force not-automatic with invalid data
     self.assertRaises(
         ValueError, details.force_not_automatic_archive_suite, "random-string")
     # force not-automatic with valid data
     self.assertTrue(details.force_not_automatic_archive_suite(
             not_automatic_version.origins[0].archive))
     # ensure we get the description of the not-automatic version
     self.assertEqual(details.description,
                      not_automatic_version.description)
     self.assertEqual(details.summary,
                      not_automatic_version.summary)
     self.assertEqual(details.version,
                      not_automatic_version.version)
     self.assertEqual(app.archive_suite,
                      not_automatic_version.origins[0].archive)
     # clearing works
     details.force_not_automatic_archive_suite("")
     self.assertEqual(app.archive_suite, "")
開發者ID:cs2c,項目名稱:AppStream,代碼行數:27,代碼來源:test_database.py

示例5: test_appdetails

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_appdetails(self):
     app = Application("Foo app", "dpkg")
     db = get_test_db()
     appdetails = app.get_details(db)
     # patching properties is a bit cumbersome
     with patch.object(AppDetails, "raw_price") as mock_price:
         with patch.object(AppDetails, "currency") as mock_currency:
             mock_price.__get__ = Mock(return_value="2.99")
             mock_currency.__get__ = Mock(return_value="USD")
             self.assertEqual("USD 2.99", appdetails.price)
開發者ID:pombredanne,項目名稱:shop,代碼行數:12,代碼來源:test_application.py

示例6: test_where_is_it_kde4

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_where_is_it_kde4(self):
     app = Application("", "ark")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file, "/usr/share/app-install/desktop/ark:kde4__ark.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(details.desktop_file, [os.path.abspath("./data/fake-applications.menu")])
     self.assertEqual(found[0].get_name(), "Applications")
     self.assertEqual(found[0].get_icon().get_names()[0], "applications-other")
     self.assertEqual(found[1].get_name(), "Accessories")
     self.assertEqual(found[1].get_icon().get_names()[0], "applications-utilities")
開發者ID:pombredanne,項目名稱:xmario_center,代碼行數:13,代碼來源:test_where_is_it.py

示例7: disabled_for_now_test_where_is_it_in_system

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def disabled_for_now_test_where_is_it_in_system(self):
     app = Application("Hardware Drivers", "jockey-gtk")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file, "/usr/share/app-install/desktop/jockey-gtk.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(details.desktop_file)
     self.assertEqual(found[0].get_name(), "Desktop")
     self.assertEqual(found[0].get_icon(), "preferences-other")
     self.assertEqual(found[1].get_name(), "Administration")
     self.assertEqual(found[1].get_icon(), "preferences-system")
開發者ID:pombredanne,項目名稱:xmario_center,代碼行數:13,代碼來源:test_where_is_it.py

示例8: test_not_automatic_channel_support

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_not_automatic_channel_support(self):
     db = get_test_db()
     app = Application("", "software-center")
     details = app.get_details(db)
     versions = [self._make_version(not_automatic=True), self._make_version(not_automatic=False)]
     details._pkg.versions = versions
     details._pkg.candidate = versions[1]
     self.assertEqual(
         details.get_not_automatic_archive_versions(),
         [(versions[1].version, "precise"), (versions[0].version, "precise-backports")],
     )
開發者ID:pombredanne,項目名稱:xmario_center,代碼行數:13,代碼來源:test_database.py

示例9: test_where_is_it_real_system

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_where_is_it_real_system(self):
     app = Application("", "gedit")
     details = app.get_details(self.db)
     if details.pkg_state != PkgStates.INSTALLED:
         logging.warn("gedit not installed, skipping real menu test")
         self.skipTest("gedit not installed")
         return
     self.assertEqual(details.desktop_file, "/usr/share/app-install/desktop/gedit:gedit.desktop")
     # search the *real* menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(details.desktop_file)
     self.assertNotEqual(found, None)
開發者ID:pombredanne,項目名稱:xmario_center,代碼行數:14,代碼來源:test_where_is_it.py

示例10: test_multiple_version_pkg_states

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_multiple_version_pkg_states(self):
     db = get_test_db()
     app = Application("", "software-center")
     details = app.get_details(db)
     normal_version = self._make_version(not_automatic=False)
     not_automatic_version = self._make_version(not_automatic=True)
     details._pkg.versions = [normal_version, not_automatic_version]
     details._pkg.installed = normal_version
     details._pkg.is_installed = True
     details._pkg.is_upgradable = True
     self.assertEqual(details.pkg_state, PkgStates.UPGRADABLE)
     app.archive_suite = not_automatic_version
     self.assertEqual(details.pkg_state, PkgStates.FORCE_VERSION)
開發者ID:cs2c,項目名稱:AppStream,代碼行數:15,代碼來源:test_database.py

示例11: test_where_is_it_in_applications

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_where_is_it_in_applications(self):
     app = Application("Calculator", "gcalctool")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file,
                      "/usr/share/app-install/desktop/gcalctool:gcalctool.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(
         details.desktop_file,
         [os.path.join(DATA_DIR, "fake-applications.menu")])
     self.assertEqual(found[0].get_name(), "Applications")
     self.assertEqual(found[0].get_icon().get_names()[0],
                      "applications-other")
     self.assertEqual(found[1].get_name(), "Accessories")
     self.assertEqual(found[1].get_icon().get_names()[0],
                      "applications-utilities")
開發者ID:pombredanne,項目名稱:shop,代碼行數:18,代碼來源:disabled_test_where_is_it.py

示例12: test_application_details

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_application_details(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, use_agent=False)
     self.assertEqual(len(db), 5)
     # test details
     app = Application("Ubuntu Software Center Test", "software-center")
     details = app.get_details(db)
     self.assertNotEqual(details, None)
     self.assertEqual(details.component, "main")
     self.assertEqual(details.pkgname, "software-center")
     # get the first document
     for doc in db:
         if doc.get_data() == "Ubuntu Software Center Test":
             appdetails = AppDetails(db, doc=doc)
             break
     # test get_appname and get_pkgname
     self.assertEqual(db.get_appname(doc), "Ubuntu Software Center Test")
     self.assertEqual(db.get_pkgname(doc), "software-center")
     # test appdetails
     self.assertEqual(appdetails.name, "Ubuntu Software Center Test")
     self.assertEqual(appdetails.pkgname, "software-center")
     # FIXME: add a dekstop file with a real channel to test
     #        and monkey-patch/modify the APP_INSTALL_CHANNELS_PATH
     self.assertEqual(appdetails.channelname, None)
     self.assertEqual(appdetails.channelfile, None)
     self.assertEqual(appdetails.component, "main")
     self.assertNotEqual(appdetails.pkg, None)
     # from the fake test/data/appdetails/var/lib/dpkg/status
     self.assertEqual(appdetails.pkg.is_installed, True)
     self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
     # FIXME: test description for unavailable pkg
     self.assertTrue(
         appdetails.description.startswith("Ubuntu Software Center lets you"))
     # FIXME: test appdetails.website
     self.assertEqual(appdetails.icon, "softwarecenter")
     # crude, crude
     self.assertTrue(len(appdetails.version) > 2)
     # FIXME: screenshots will only work on ubuntu
     self.assertTrue(re.match(
             "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+", 
             appdetails.screenshot))
     self.assertTrue(re.match(
             "http://screenshots.ubuntu.com/thumbnail-with-version/software-center/[\d.]+",
             appdetails.thumbnail))
     # FIXME: add document that has a price
     self.assertEqual(appdetails.price, '')
     self.assertEqual(appdetails.license, "Open source")
     # test lazy history loading for installation date
     self.ensure_installation_date_and_lazy_history_loading(appdetails)
     # test apturl replacements
     # $kernel
     app = Application("", "linux-headers-$kernel", "channel=$distro-partner")
     self.assertEqual(app.pkgname, 'linux-headers-'+os.uname()[2])
     # $distro
     details = app.get_details(db)
     from softwarecenter.distro import get_distro
     distro = get_distro().get_codename()
     self.assertEqual(app.request, 'channel=' + distro + '-partner')
開發者ID:armikhael,項目名稱:software-center,代碼行數:64,代碼來源:test_database.py

示例13: test_application_details

# 需要導入模塊: from softwarecenter.db.application import Application [as 別名]
# 或者: from softwarecenter.db.application.Application import get_details [as 別名]
 def test_application_details(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, use_agent=False)
     self.assertEqual(len(db), 6)
     # test details
     app = Application("Ubuntu Software Center Test", "software-center")
     details = app.get_details(db)
     self.assertNotEqual(details, None)
     # mvo: disabled, we can reenable this once there is a static
     #      apt rootdir and we do not rely on the test system to
     #      have software-center from the main archive and not from
     #      e.g. a custom repo like the ADT environment
     # self.assertEqual(details.component, "main")
     self.assertEqual(details.pkgname, "software-center")
     # get the first document
     for doc in db:
         if doc.get_data() == "Ubuntu Software Center Test":
             appdetails = AppDetails(db, doc=doc)
             break
     # test get_appname and get_pkgname
     self.assertEqual(db.get_appname(doc), "Ubuntu Software Center Test")
     self.assertEqual(db.get_pkgname(doc), "software-center")
     # test appdetails
     self.assertEqual(appdetails.name, "Ubuntu Software Center Test")
     self.assertEqual(appdetails.pkgname, "software-center")
     # FIXME: add a dekstop file with a real channel to test
     #        and monkey-patch/modify the APP_INSTALL_CHANNELS_PATH
     self.assertEqual(appdetails.channelname, None)
     self.assertEqual(appdetails.channelfile, None)
     self.assertNotEqual(appdetails.pkg, None)
     # from the fake test/data/appdetails/var/lib/dpkg/status
     self.assertEqual(appdetails.pkg.is_installed, True)
     self.assertTrue(appdetails.pkg_state in (PkgStates.INSTALLED, PkgStates.UPGRADABLE))
     # FIXME: test description for unavailable pkg
     self.assertTrue(appdetails.description.startswith("Ubuntu Software Center lets you"))
     # FIXME: test appdetails.website
     self.assertEqual(appdetails.icon, "softwarecenter")
     # crude, crude
     self.assertTrue(len(appdetails.version) > 2)
     # FIXME: screenshots will only work on ubuntu
     self.assertTrue(
         re.match(
             "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+", appdetails.screenshot
         )
     )
     self.assertTrue(
         re.match(
             "http://screenshots.ubuntu.com/thumbnail-with-version/software-center/[\d.]+", appdetails.thumbnail
         )
     )
     # FIXME: add document that has a price
     self.assertEqual(appdetails.price, "Free")
     self.assertEqual(appdetails.raw_price, "")
     # mvo: disabled, we can reenable this once there is a static
     #      apt rootdir and we do not rely on the test system to
     #      have software-center from the main archive and not from
     #      e.g. a custom repo like the ADT environment
     # self.assertEqual(appdetails.license, "Open source")
     # test lazy history loading for installation date
     self.ensure_installation_date_and_lazy_history_loading(appdetails)
     # test apturl replacements
     # $kernel
     app = Application("", "linux-headers-$kernel", "channel=$distro-partner")
     self.assertEqual(app.pkgname, "linux-headers-" + os.uname()[2])
     # $distro
     details = app.get_details(db)
     distro = softwarecenter.distro.get_distro().get_codename()
     self.assertEqual(app.request, "channel=" + distro + "-partner")
開發者ID:mortenpi,項目名稱:ubuntu-software-center,代碼行數:73,代碼來源:test_database.py


注:本文中的softwarecenter.db.application.Application.get_details方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。