本文整理汇总了Python中distro_info.UbuntuDistroInfo方法的典型用法代码示例。如果您正苦于以下问题:Python distro_info.UbuntuDistroInfo方法的具体用法?Python distro_info.UbuntuDistroInfo怎么用?Python distro_info.UbuntuDistroInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distro_info
的用法示例。
在下文中一共展示了distro_info.UbuntuDistroInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_release_from_distro_info
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def get_release_from_distro_info(string):
"""Convert an Ubuntu release or version into a release dict.
This data is pulled from the UbuntuDistroInfo library which contains
additional information such as the release, EOL, and code name."""
ubuntu = UbuntuDistroInfo()
release_found = False
# We can only look at release names for 12.04+ as previous versions
# have overlapping first letters(e.g Warty and Wily) which break looking
# up old style kernels(e.g hwe-w).
try:
ubuntu_rows = ubuntu._rows
except AttributeError:
ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
for row in ubuntu_rows:
if (
int(row['version'].split('.')[0]) >= 12 and
row['series'].startswith(string) or
row['version'].startswith(string)):
release_found = True
break
if release_found:
return row
else:
return None
示例2: test_get_supported_commissioning_releases_excludes_unsupported_lts
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def test_get_supported_commissioning_releases_excludes_unsupported_lts(
self):
self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
'precise', 'trusty', 'vivid', 'wily', 'xenial'
]
unsupported = [
'warty', 'hoary', 'breezy', 'dapper', 'edgy', 'feisty', 'gutsy',
'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid', 'maverick',
'natty', 'oneiric', 'quantal', 'raring', 'saucy', 'utopic'
]
self.patch_autospec(
UbuntuDistroInfo, "unsupported").return_value = unsupported
osystem = UbuntuOS()
releases = osystem.get_supported_commissioning_releases()
self.assertIsInstance(releases, list)
for release in unsupported:
self.assertNotIn(release, releases)
示例3: get_ubuntu_releases
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def get_ubuntu_releases(self):
"""Return a list of all Ubuntu releases in order of release."""
_d = distro_info.UbuntuDistroInfo()
_release_list = _d.all
return _release_list
示例4: test_cross_vendor
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def test_cross_vendor(self):
c = self.__config
c.vendor = 'steamrt'
c.suite = 'scout'
steamrt = c.get_vendor('steamrt')
ubuntu = c.get_vendor('ubuntu')
scout = c.get_suite(steamrt, 'scout')
precise = c.get_suite(ubuntu, 'precise')
self.assertEqual(list(scout.hierarchy), [scout, precise])
self.assertEqual(c.components, {'main', 'contrib', 'non-free'})
self.assertEqual(c.vendor, steamrt)
# TODO: not sure whether it's correct for these to be inherited
# from Ubuntu due to the cross-vendor base suite?
self.assertIs(c.worker_vendor, ubuntu)
self.assertIs(c.sbuild_worker_vendor, ubuntu)
self.assertIs(c.vmdebootstrap_worker_vendor, ubuntu)
# TODO: not sure whether it's correct for these to be inherited
# from Ubuntu due to the cross-vendor base suite?
self.assertEqual(c.autopkgtest, ['lxc', 'qemu'])
self.assertEqual(
c.get_mirrors().lookup_suite(scout),
'http://192.168.122.1:3142/repo.steamstatic.com/steamrt')
self.assertEqual(scout.archive, 'repo.steamstatic.com/steamrt')
try:
import distro_info
except ImportError:
return
ubuntu_info = distro_info.UbuntuDistroInfo()
self.assertIs(
c.worker_suite,
c.get_suite(ubuntu, ubuntu_info.lts() + '-backports'))
示例5: pick_release
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def pick_release(self):
ubuntu = UbuntuDistroInfo()
try:
ubuntu_rows = ubuntu._rows
except AttributeError:
ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
supported_releases = [
release for release in ubuntu_rows
if int(release['version'].split('.')[0]) >= 12
]
return random.choice(supported_releases)
示例6: make_boot_source_cache
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def make_boot_source_cache(self):
# Disable boot sources signals otherwise the test fails due to unrun
# post-commit tasks at the end of the test.
self.useFixture(SignalsDisabled("bootsources"))
ubuntu = UbuntuDistroInfo()
try:
ubuntu_rows = ubuntu._rows
except AttributeError:
ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
supported_releases = [
release for release in ubuntu_rows
if int(release['version'].split('.')[0]) >= 12
]
release = random.choice(supported_releases)
ga_or_hwe = random.choice(['hwe', 'ga'])
subarch = "%s-%s" % (ga_or_hwe, release['version'].split(' ')[0])
factory.make_BootSourceCache(
os='ubuntu',
arch=factory.make_name('arch'),
subarch=subarch,
release=release['series'],
release_codename=release['codename'],
release_title=release['version'],
support_eol=release.get('eol_server', release.get('eol-server')),
)
return release
示例7: get_distro_series_info_row
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def get_distro_series_info_row(series):
"""Returns the distro series row information from python-distro-info.
"""
info = UbuntuDistroInfo()
for row in info._avail(info._date):
# LP: #1711191 - distro-info 0.16+ no longer returns dictionaries or
# lists, and it now returns objects instead. As such, we need to
# handle both cases for backwards compatibility.
if not isinstance(row, dict):
row = row.__dict__
if row['series'] == series:
return row
return None
示例8: make_boot_sources
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def make_boot_sources(self):
kernels = []
ubuntu = UbuntuDistroInfo()
# LP: #1711191 - distro-info 0.16+ no longer returns dictionaries or
# lists, and it now returns objects instead. As such, we need to
# handle both cases for backwards compatibility.
try:
ubuntu_rows = ubuntu._rows
except AttributeError:
ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
for row in ubuntu_rows:
release_year = int(row['version'].split('.')[0])
if release_year < 12:
continue
elif release_year < 16:
style = row['series'][0]
else:
style = row['version']
for kflavor in [
'generic', 'lowlatency', 'edge', 'lowlatency-edge']:
if kflavor == 'generic':
kernel = "hwe-%s" % style
else:
kernel = "hwe-%s-%s" % (style, kflavor)
arch = factory.make_name('arch')
architecture = "%s/%s" % (arch, kernel)
release = row['series'].split(' ')[0]
factory.make_usable_boot_resource(
name="ubuntu/" + release,
kflavor=kflavor,
extra={'subarches': kernel},
architecture=architecture,
rtype=BOOT_RESOURCE_TYPE.SYNCED)
factory.make_BootSourceCache(
os="ubuntu",
arch=arch,
subarch=kernel,
release=release)
kernels.append(
(kernel, '%s (%s)' % (release, kernel)))
return kernels
示例9: __init__
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def __init__(self):
self.ubuntu_distro_info = UbuntuDistroInfo()
示例10: get_lts_release
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def get_lts_release(self):
return UbuntuDistroInfo().lts()
示例11: get_release_title
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def get_release_title(self, release):
info = UbuntuDistroInfo()
for row in info._avail(info._date):
row_dict = row
if not isinstance(row, dict):
row_dict = row.__dict__
if row_dict['series'] == release:
return info._format("fullname", row)
return None
示例12: test_is_release_supported
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def test_is_release_supported(self):
osystem = UbuntuOS()
info = UbuntuDistroInfo()
self.assertTrue(osystem.is_release_supported(random.choice(info.all)))
示例13: test_get_supported_commissioning_releases
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def test_get_supported_commissioning_releases(self):
self.patch_autospec(UbuntuDistroInfo, "is_lts").return_value = True
self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
'precise', 'trusty', 'vivid', 'wily', 'xenial'
]
osystem = UbuntuOS()
releases = osystem.get_supported_commissioning_releases()
self.assertIsInstance(releases, list)
self.assertSequenceEqual(
['trusty', 'vivid', 'wily', 'xenial'], releases)
示例14: test_get_supported_commissioning_releases_excludes_precise
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def test_get_supported_commissioning_releases_excludes_precise(self):
"""Make sure we remove 'precise' from the list."""
self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
'precise', 'trusty', 'vivid', 'wily', 'xenial'
]
osystem = UbuntuOS()
releases = osystem.get_supported_commissioning_releases()
self.assertIsInstance(releases, list)
self.assertNotIn('precise', releases)
示例15: test_get_release_title
# 需要导入模块: import distro_info [as 别名]
# 或者: from distro_info import UbuntuDistroInfo [as 别名]
def test_get_release_title(self):
osystem = UbuntuOS()
info = UbuntuDistroInfo()
release = random.choice(info.all)
self.assertEqual(
osystem.get_release_title(release),
self.get_release_title(release))