本文整理汇总了Python中softwarecenter.distro.get_distro函数的典型用法代码示例。如果您正苦于以下问题:Python get_distro函数的具体用法?Python get_distro怎么用?Python get_distro使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_distro函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, repo):
if repo:
repo_id = repo.get_property("repo-id")
if repo_id.endswith("-source"):
repo_id = repo_id[: -len("-source")]
self.component = "source"
elif repo_id.endswith("-debuginfo"):
repo_id = repo_id[: -len("-debuginfo")]
self.component = "debuginfo"
else:
self.component = "main"
if repo_id == "updates":
self.origin = get_distro().get_distro_channel_name()
self.archive = "stable"
elif repo_id == "updates-testing":
self.origin = get_distro().get_distro_channel_name()
self.archive = "testing"
elif repo_id.endswith("-updates-testing"):
self.origin = repo_id[: -len("-updates-testing")]
self.archive = "testing"
else:
self.origin = repo_id
self.archive = "stable"
self.trusted = True
self.label = repo.get_property("description")
else:
self.origin = "unknown"
self.archive = "unknown"
self.trusted = False
self.label = _("Unknown repository")
self.component = "main"
self.site = ""
示例2: __init__
def __init__(self, repo):
if repo:
repo_id = repo.get_property('repo-id')
if repo_id.endswith('-source'):
repo_id = repo_id[:-len('-source')]
self.component = 'source'
elif repo_id.endswith('-debuginfo'):
repo_id = repo_id[:-len('-debuginfo')]
self.component = 'debuginfo'
else:
self.component = 'main'
if repo_id == 'updates':
self.origin = get_distro().get_distro_channel_name()
self.archive = 'stable'
elif repo_id == 'updates-testing':
self.origin = get_distro().get_distro_channel_name()
self.archive = 'testing'
elif repo_id.endswith('-updates-testing'):
self.origin = repo_id[:-len('-updates-testing')]
self.archive = 'testing'
else:
self.origin = repo_id
self.archive = 'stable'
self.trusted = True
self.label = repo.get_property('description')
else:
self.origin = 'unknown'
self.archive = 'unknown'
self.trusted = False
self.label = _("Unknown repository")
self.component = 'main'
self.site = ''
示例3: test_new_no_sort_info_yet
def test_new_no_sort_info_yet(self):
# ensure that we don't show a empty "whats new" category
# see LP: #865985
from softwarecenter.testutils import get_test_db
db = get_test_db()
cache = db._aptcache
# simulate a fresh install with no catalogedtime info
del db._axi_values["catalogedtime"]
from softwarecenter.testutils import get_test_gtk3_icon_cache
icons = get_test_gtk3_icon_cache()
from softwarecenter.db.appfilter import AppFilter
apps_filter = AppFilter(db, cache)
from softwarecenter.distro import get_distro
from softwarecenter.ui.gtk3.views.catview_gtk import LobbyViewGtk
view = LobbyViewGtk(softwarecenter.paths.datadir,
softwarecenter.paths.APP_INSTALL_PATH,
cache, db, icons, get_distro(), apps_filter)
view.show()
# gui
win = Gtk.Window()
self.addCleanup(win.destroy)
win.set_size_request(800, 400)
scroll = Gtk.ScrolledWindow()
scroll.add(view)
scroll.show()
win.add(scroll)
win.show()
# test visibility
do_events()
self.assertFalse(view.whats_new_frame.get_property("visible"))
示例4: __init__
def __init__(self, datadir, db, icons):
gtk.TreeStore.__init__(self, AnimatedImage, str, int, gobject.TYPE_PYOBJECT)
self.icons = icons
self.datadir = datadir
self.backend = get_install_backend()
self.backend.connect("transactions-changed", self.on_transactions_changed)
self.backend.connect("channels-changed", self.on_channels_changed)
self.db = db
self.distro = get_distro()
# pending transactions
self._pending = 0
# setup the normal stuff
available_icon = self._get_icon("softwarecenter")
self.available_iter = self.append(None, [available_icon, _("Get Software"), self.ACTION_ITEM_AVAILABLE, None])
# do initial channel list update
self._update_channel_list()
icon = AnimatedImage(self.icons.load_icon("computer", self.ICON_SIZE, 0))
installed_iter = self.append(None, [icon, _("Installed Software"), self.ACTION_ITEM_INSTALLED, None])
icon = AnimatedImage(None)
self.append(None, [icon, "<span size='1'> </span>", self.ACTION_ITEM_SEPARATOR_1, None])
# kick off a background check for changes that may have been made
# in the channels list
glib.timeout_add(300, lambda: self._check_for_channel_updates(self.channels))
示例5: component
def component(self):
"""
get the component (main, universe, ..)
this uses the data from apt, if there is none it uses the
data from the app-install-data files
"""
# try apt first
if self._pkg:
for origin in self._pkg.candidate.origins:
if (origin.origin == get_distro().get_distro_channel_name() and
origin.trusted and origin.component):
return origin.component
# then xapian
elif self._doc:
comp = self._doc.get_value(XapianValues.ARCHIVE_SECTION)
return comp
# then apturl requests
else:
section_matches = re.findall(r'section=([a-z]+)',
self._app.request)
if section_matches:
valid_section_matches = []
for section_match in section_matches:
if (self._unavailable_component(
component_to_check=section_match) and
valid_section_matches.count(section_match) == 0):
valid_section_matches.append(section_match)
if valid_section_matches:
return ('&').join(valid_section_matches)
示例6: __init__
def __init__(self, channel_name, channel_origin, channel_component,
source_entry=None, installed_only=False,
channel_icon=None, channel_query=None,
channel_sort_mode=SortMethods.BY_ALPHABET):
"""
configure the software channel object based on channel name,
origin, and component (the latter for detecting the partner
channel)
"""
self._channel_name = channel_name
self._channel_origin = channel_origin
self._channel_component = channel_component
self._channel_color = None
self._channel_view_id = None
self.installed_only = installed_only
self._channel_sort_mode = channel_sort_mode
# distro specific stuff
self.distro = get_distro()
# configure the channel
self._channel_display_name = self._get_display_name_for_channel(channel_name, channel_component)
if channel_icon is None:
self._channel_icon = self._get_icon_for_channel(channel_name, channel_origin, channel_component)
else:
self._channel_icon = channel_icon
if channel_query is None:
self._channel_query = self._get_channel_query_for_channel(channel_name, channel_origin, channel_component)
else:
self._channel_query = channel_query
# a sources.list entry attached to the channel (this is currently
# only used for not-yet-enabled channels)
self._source_entry = source_entry
# when the channel needs to be added to the systems sources.list
self.needs_adding = False
示例7: __init__
def __init__(self, db, doc=None, application=None):
""" Create a new AppDetails object. It can be created from
a xapian.Document or from a db.application.Application object
"""
GObject.GObject.__init__(self)
if not doc and not application:
raise ValueError("Need either document or application")
self._db = db
self._db.connect("reopen", self._on_db_reopen)
self._cache = self._db._aptcache
self._distro = get_distro()
self._history = None
# import here (intead of global) to avoid dbus dependency
# in update-software-center (that imports application, but
# never uses AppDetails) LP: #620011
from softwarecenter.backend import get_install_backend
self._backend = get_install_backend()
# FIXME: why two error states ?
self._error = None
self._error_not_found = None
self._screenshot_list = None
# load application
self._app = application
if doc:
self._app = Application(self._db.get_appname(doc),
self._db.get_pkgname(doc),
"")
# sustitute for apturl
if self._app.request:
self._app.request = self._app.request.replace(
"$distro", self._distro.get_codename())
# load pkg cache
self._pkg = None
if (self._app.pkgname in self._cache and
self._cache[self._app.pkgname].candidate):
self._pkg = self._cache[self._app.pkgname]
# load xapian document
self._doc = doc
if not self._doc:
try:
self._doc = self._db.get_xapian_document(
self._app.appname, self._app.pkgname)
except IndexError:
# if there is no document and no apturl request,
# set error state
debfile_matches = re.findall(r'/', self._app.request)
channel_matches = re.findall(r'channel=[a-z,-]*',
self._app.request)
section_matches = re.findall(r'section=[a-z]*',
self._app.request)
if (not self._pkg and
not debfile_matches and
not channel_matches and
not section_matches):
self._error = _("Not found")
self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname)
示例8: test_ping
def test_ping(host=None):
global NETWORK_STATE
import subprocess
# ping the screenshots provider
from softwarecenter.distro import get_distro
distro = get_distro()
host = urlparse(distro.SCREENSHOT_LARGE_URL)[1]
msg = ("Attempting one time ping of %s to test if internet "
"connectivity exists." % host)
logging.info(msg)
ping = subprocess.Popen(["ping", "-c", "1", host],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, error = ping.communicate()
res = ping.wait()
if res != 0:
NETWORK_STATE = NetState.NM_STATE_DISCONNECTED
msg = "Could not detect an internet connection\n%s" % error
else:
NETWORK_STATE = NetState.NM_STATE_CONNECTED_GLOBAL
msg = "Internet connection available!\n%s" % out
__WATCHER__.emit("changed", NETWORK_STATE)
logging.info("ping output: '%s'" % msg)
return NETWORK_STATE
示例9: __init__
def __init__(self, db, cache):
self.distro = get_distro()
self.db = db
self.cache = cache
self.supported_only = False
self.installed_only = False
self.not_installed_only = False
self.only_packages_without_applications = False
示例10: __init__
def __init__(self):
super(PackagekitInfo, self).__init__()
self.client = packagekit.Client()
self.client.set_locale(make_locale_string())
self._cache = {} # temporary hack for decent testing
self._notfound_cache = []
self._repocache = {}
self.distro = get_distro()
示例11: __init__
def __init__(self, db, backend, icons):
GObject.GObject.__init__(self)
self._globalise_instance()
self.db = db
self.backend = backend
self.distro = get_distro()
self.datadir = softwarecenter.paths.datadir
self.icons = icons
示例12: test_distro_functions
def test_distro_functions(self):
distro = get_distro()
codename = distro.get_codename()
self.assertNotEqual(codename, None)
myname = distro.get_app_name()
self.assertTrue(len(myname) > 0)
arch = distro.get_architecture()
self.assertNotEqual(arch, None)
示例13: update_debline
def update_debline(cls, debline):
# Be careful to handle deblines with pockets.
source_entry = SourceEntry(debline)
distro_pocket = source_entry.dist.split('-')
distro_pocket[0] = get_distro().get_codename()
source_entry.dist = "-".join(distro_pocket)
return unicode(source_entry)
示例14: index
def index(self, document, pkg):
"""
Update the document with the information from this data source.
document is the document to update
pkg is the python-apt Package object for this package
"""
ver = pkg.candidate
# if there is no version or the AppName custom key is not
# found we can skip the pkg
if ver is None or not CustomKeys.APPNAME in ver.record:
return
# we want to index the following custom fields:
# XB-AppName,
# XB-Icon,
# XB-Screenshot-Url,
# XB-Thumbnail-Url,
# XB-Category
if CustomKeys.APPNAME in ver.record:
name = ver.record[CustomKeys.APPNAME]
self.indexer.set_document(document)
# add s-c values/terms for the name
document.add_term("AA"+name)
document.add_value(XapianValues.APPNAME, name)
for t in get_pkgname_terms(pkg.name):
document.add_term(t)
self.indexer.index_text_without_positions(
name, WEIGHT_DESKTOP_NAME)
# we pretend to be an application
document.add_term("AT" + "application")
# and we inject a custom component value to indicate "independent"
document.add_value(XapianValues.ARCHIVE_SECTION, "independent")
if CustomKeys.ICON in ver.record:
icon = ver.record[CustomKeys.ICON]
document.add_value(XapianValues.ICON, icon)
# calculate the url and add it (but only if there actually is
# a url)
try:
distro = get_distro()
if distro:
base_uri = ver.uri
# new python-apt returns None instead of StopIteration
if base_uri:
url = distro.get_downloadable_icon_url(base_uri, icon)
document.add_value(XapianValues.ICON_URL, url)
except StopIteration:
pass
if CustomKeys.SCREENSHOT_URLS in ver.record:
screenshot_url = ver.record[CustomKeys.SCREENSHOT_URLS]
document.add_value(XapianValues.SCREENSHOT_URLS, screenshot_url)
if CustomKeys.THUMBNAIL_URL in ver.record:
url = ver.record[CustomKeys.THUMBNAIL_URL]
document.add_value(XapianValues.THUMBNAIL_URL, url)
if CustomKeys.CATEGORY in ver.record:
categories_str = ver.record[CustomKeys.CATEGORY]
for cat in categories_str.split(";"):
if cat:
document.add_term("AC" + cat.lower())
示例15: setUp
def setUp(self):
from softwarecenter.backend import zeitgeist_logger
if not zeitgeist_logger.HAVE_MODULE:
self.skipTest("Zeitgeist module missing, impossible to test")
from zeitgeist import datamodel
self.distro = get_distro()
self.logger = ZeitgeistLogger(self.distro)
self.datamodel = datamodel