本文整理汇总了Python中softwarecenter.db.application.Application类的典型用法代码示例。如果您正苦于以下问题:Python Application类的具体用法?Python Application怎么用?Python Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_most_popular_applications_for_mimetype
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,代码行数:26,代码来源:database.py
示例2: test_not_automatic_version
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,代码行数:25,代码来源:test_database.py
示例3: __init__
def __init__(self, debfile):
# sanity check
if not debfile.endswith(".deb"):
raise ValueError("Need a deb file, got '%s'" % debfile)
# work out debname/appname
debname = os.path.splitext(os.path.basename(debfile))[0]
pkgname = debname.split('_')[0].lower()
# call the constructor
Application.__init__(self, pkgname=pkgname, request=debfile)
开发者ID:feiying,项目名称:AppStream,代码行数:9,代码来源:debfile.py
示例4: __init__
def __init__(self, debfile):
if not is_deb_file(debfile):
raise DebFileOpenError("Could not open %r." % debfile, debfile)
# work out debname/appname
debname = os.path.splitext(os.path.basename(debfile))[0]
pkgname = debname.split('_')[0].lower()
# call the constructor
Application.__init__(self, pkgname=pkgname, request=debfile)
开发者ID:fossasia,项目名称:x-mario-center,代码行数:9,代码来源:debfile.py
示例5: test_appdetails
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,代码行数:10,代码来源:test_application.py
示例6: test_where_is_it_kde4
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,代码行数:11,代码来源:test_where_is_it.py
示例7: disabled_for_now_test_where_is_it_in_system
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,代码行数:11,代码来源:test_where_is_it.py
示例8: test_not_automatic_channel_support
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,代码行数:11,代码来源:test_database.py
示例9: test_where_is_it_real_system
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,代码行数:12,代码来源:test_where_is_it.py
示例10: test_multiple_version_pkg_states
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,代码行数:13,代码来源:test_database.py
示例11: 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
示例12: 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
示例13: test_where_is_it_in_applications
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,代码行数:16,代码来源:disabled_test_where_is_it.py
示例14: get_exact_matches
def get_exact_matches(self, pkgnames=[]):
""" Returns a list of fake MSetItems. If the pkgname is available, then
MSetItem.document is pkgnames proper xapian document. If the pkgname
is not available, then MSetItem is actually an Application. """
matches = []
for pkgname in pkgnames:
app = Application('', pkgname.split('?')[0])
if '?' in pkgname:
app.request = pkgname.split('?')[1]
match = app
for m in self.xapiandb.postlist("XP"+app.pkgname):
match = self.xapiandb.get_document(m.docid)
for m in self.xapiandb.postlist("AP"+app.pkgname):
match = self.xapiandb.get_document(m.docid)
matches.append(FakeMSetItem(match))
return matches
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:16,代码来源:database.py
示例15: test_application_details
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,代码行数:62,代码来源:test_database.py
示例16: test_application_details
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,代码行数:71,代码来源:test_database.py
注:本文中的softwarecenter.db.application.Application类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论