本文整理汇总了Python中softwarecenter.db.pkginfo.get_pkg_info函数的典型用法代码示例。如果您正苦于以下问题:Python get_pkg_info函数的具体用法?Python get_pkg_info怎么用?Python get_pkg_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_pkg_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: 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
示例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: rebuild_database
def rebuild_database(pathname, debian_sources=True, appstream_sources=False):
#cache = apt.Cache(memonly=True)
cache = get_pkg_info()
cache.open()
old_path = pathname+"_old"
rebuild_path = pathname+"_rb"
if not os.path.exists(rebuild_path):
try:
os.makedirs(rebuild_path)
except:
LOG.warn("Problem creating rebuild path '%s'." % rebuild_path)
LOG.warn("Please check you have the relevant permissions.")
return False
# check permission
if not os.access(pathname, os.W_OK):
LOG.warn("Cannot write to '%s'." % pathname)
LOG.warn("Please check you have the relevant permissions.")
return False
#check if old unrequired version of db still exists on filesystem
if os.path.exists(old_path):
LOG.warn("Existing xapian old db was not previously cleaned: '%s'." % old_path)
if os.access(old_path, os.W_OK):
#remove old unrequired db before beginning
shutil.rmtree(old_path)
else:
LOG.warn("Cannot write to '%s'." % old_path)
LOG.warn("Please check you have the relevant permissions.")
return False
# write it
db = xapian.WritableDatabase(rebuild_path, xapian.DB_CREATE_OR_OVERWRITE)
if debian_sources:
update(db, cache)
if appstream_sources:
update_from_appstream_xml(db, cache)
# write the database version into the filep
db.set_metadata("db-schema-version", DB_SCHEMA_VERSION)
# update the mo file stamp for the langpack checks
mofile = gettext.find("app-install-data")
if mofile:
mo_time = os.path.getctime(mofile)
db.set_metadata("app-install-mo-time", str(mo_time))
db.flush()
# use shutil.move() instead of os.rename() as this will automatically
# figure out if it can use os.rename or needs to do the move "manually"
try:
shutil.move(pathname, old_path)
shutil.move(rebuild_path, pathname)
shutil.rmtree(old_path)
return True
except:
LOG.warn("Cannot copy refreshed database to correct location: '%s'." % pathname)
return False
开发者ID:armikhael,项目名称:software-center,代码行数:60,代码来源:update.py
示例6: 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
示例7: test_memleak_pkginfo_open
def test_memleak_pkginfo_open(self):
cache = get_pkg_info()
cache.open()
do_events_with_sleep()
with TraceMemoryUsage("PackageInfo.open()"):
for i in range(self.ITERATIONS):
cache.open()
do_events_with_sleep()
开发者ID:pombredanne,项目名称:shop,代码行数:8,代码来源:disabled_test_memleak.py
示例8: get_test_db_from_app_install_data
def get_test_db_from_app_install_data(datadir):
db = xapian.inmemory_open()
cache = get_pkg_info()
cache.open()
res = update_from_app_install_data(db, cache, datadir)
if res is False:
raise AssertionError("Failed to build db from '%s'" % datadir)
return db
开发者ID:pombredanne,项目名称:shop,代码行数:8,代码来源:utils.py
示例9: get_installed_package_list
def get_installed_package_list():
""" return a set of all of the currently installed packages """
from softwarecenter.db.pkginfo import get_pkg_info
installed_pkgs = set()
cache = get_pkg_info()
for pkg in cache:
if pkg.is_installed:
installed_pkgs.add(pkg.name)
return installed_pkgs
开发者ID:feiying,项目名称:AppStream,代码行数:9,代码来源:utils.py
示例10: __init__
def __init__(self, parent=None):
super(ReviewsListModel, self).__init__()
self._reviews = []
roles = dict(enumerate(ReviewsListModel.COLUMNS))
self.setRoleNames(roles)
# FIXME: make this async
self.cache = get_pkg_info()
self.reviews = get_review_loader(self.cache)
开发者ID:feiying,项目名称:AppStream,代码行数:9,代码来源:reviewslist.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: 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
示例13: get_test_window_catview
def get_test_window_catview(db=None, selected_category="Internet"):
'''
Note that selected_category must specify a category that includes
subcategories, else a ValueError will be raised.
'''
def on_category_selected(view, cat):
print("on_category_selected view: ", view)
print("on_category_selected cat: ", cat)
if db is None:
cache = pkginfo.get_pkg_info()
cache.open()
xapian_base_path = "/var/cache/software-center"
pathname = os.path.join(xapian_base_path, "xapian")
db = database.StoreDatabase(pathname, cache)
db.open()
else:
cache = db._aptcache
icons = get_sc_icon_theme()
distro = softwarecenter.distro.get_distro()
apps_filter = appfilter.AppFilter(db, cache)
# gui
notebook = Gtk.Notebook()
lobby_view = lobbyview.LobbyView(cache, db, icons, distro, apps_filter)
scroll = Gtk.ScrolledWindow()
scroll.add(lobby_view)
notebook.append_page(scroll, Gtk.Label.new("Lobby"))
subcat_cat = None
for cat in lobby_view.categories:
if cat.name == selected_category:
if not cat.subcategories:
raise ValueError('The value specified for selected_category '
'*must* specify a '
'category that contains subcategories!!')
subcat_cat = cat
break
subcat_view = catview.SubCategoryView(cache, db, icons, apps_filter)
subcat_view.connect("category-selected", on_category_selected)
subcat_view.set_subcategory(subcat_cat)
scroll = Gtk.ScrolledWindow()
scroll.add(subcat_view)
notebook.append_page(scroll, Gtk.Label.new("Subcats"))
win = get_test_window(child=notebook, width=800, height=800)
win.set_data("subcat", subcat_view)
win.set_data("lobby", lobby_view)
return win
开发者ID:mortenpi,项目名称:ubuntu-software-center,代码行数:55,代码来源:windows.py
示例14: __init__
def __init__(self, parent=None):
super(ReviewsListModel, self).__init__()
self._reviews = []
roles = dict(enumerate(ReviewsListModel.COLUMNS))
self.setRoleNames(roles)
# FIXME: make this async
self.cache = get_pkg_info()
self.reviews = get_review_loader(self.cache)
self.reviews.connect("refresh-review-stats-finished", self._on_refresh_review_stats_finished)
self.reviews.connect("get-reviews-finished", self._on_reviews_ready_callback)
开发者ID:pombredanne,项目名称:shop,代码行数:11,代码来源:reviewslist.py
示例15: __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
示例16: test_memleak_app_recommendations
def test_memleak_app_recommendations(self):
cache = get_pkg_info()
cache.open(blocking=True)
win = get_test_window_appdetails()
view = win.get_data("view")
app = Application("", "gedit")
# get baseline
view.show_app(app)
do_events_with_sleep()
with TraceMemoryUsage("AppdetailsView.show_app()"):
with TraceActiveObjectTypes("view.recommended_for_app.set_pkgname"):
for i in range(self.ITERATIONS):
view.recommended_for_app_panel.set_pkgname("gedit")
cache.open()
do_events_with_sleep()
开发者ID:pombredanne,项目名称:shop,代码行数:15,代码来源:disabled_test_memleak.py
示例17: test_memleak_appdetails
def test_memleak_appdetails(self):
cache = get_pkg_info()
cache.open(blocking=True)
win = get_test_window_appdetails()
view = win.get_data("view")
app = Application("", "gedit")
# get baseline
view.show_app(app)
do_events_with_sleep()
with TraceMemoryUsage("AppdetailsView.show_app()"):
for i in range(self.ITERATIONS):
view.show_app(app, force=True)
# this causes a huge memleak of ~35mb/run
cache.open()
do_events_with_sleep()
开发者ID:pombredanne,项目名称:shop,代码行数:15,代码来源:disabled_test_memleak.py
示例18: test_memleak_app
def test_memleak_app(self):
options = Mock()
options.display_navlog = False
args = []
# ensure the cache is fully ready before taking the baseline
cache = get_pkg_info()
cache.open(blocking=True)
app = SoftwareCenterAppGtk3(options, args)
app.window_main.show_all()
do_events_with_sleep()
with TraceMemoryUsage("app._on_transaction_finished"):
for i in range(self.ITERATIONS):
app._on_transaction_finished(None, None)
cache.open()
do_events_with_sleep()
开发者ID:pombredanne,项目名称:shop,代码行数:15,代码来源:disabled_test_memleak.py
示例19: get_test_window_pkgnamesview
def get_test_window_pkgnamesview():
cache = pkginfo.get_pkg_info()
cache.open()
xapian_base_path = "/var/cache/software-center"
pathname = os.path.join(xapian_base_path, "xapian")
db = database.StoreDatabase(pathname, cache)
db.open()
icons = get_sc_icon_theme()
pkgs = ["apt", "software-center"]
view = pkgnamesview.PackageNamesView("header", cache, pkgs, icons, 32, db)
view.show()
win = get_test_window(child=view)
return win
开发者ID:mortenpi,项目名称:ubuntu-software-center,代码行数:16,代码来源:windows.py
示例20: __init__
def __init__(self, pathname=None, cache=None):
GObject.GObject.__init__(self)
if pathname is None:
pathname = softwarecenter.paths.XAPIAN_PATH
self._db_pathname = pathname
if cache is None:
cache = get_pkg_info()
self._aptcache = cache
self._additional_databases = []
# the xapian values as read from /var/lib/apt-xapian-index/values
self._axi_values = {}
self._logger = logging.getLogger("softwarecenter.db")
# we open one db per thread, thread names are reused eventually
# so no memory leak
self._db_per_thread = {}
self._parser_per_thread = {}
开发者ID:cs2c,项目名称:AppStream,代码行数:16,代码来源:database.py
注:本文中的softwarecenter.db.pkginfo.get_pkg_info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论