本文整理汇总了Python中kiwi.defaults.Defaults.is_buildservice_worker方法的典型用法代码示例。如果您正苦于以下问题:Python Defaults.is_buildservice_worker方法的具体用法?Python Defaults.is_buildservice_worker怎么用?Python Defaults.is_buildservice_worker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.defaults.Defaults
的用法示例。
在下文中一共展示了Defaults.is_buildservice_worker方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: translate
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import is_buildservice_worker [as 别名]
def translate(self, check_build_environment=True):
"""
Translate repository location according to their URI type
Depending on the URI type the provided location needs to
be adapted e.g loop mounted in case of an ISO or updated
by the service URL in case of an open buildservice project
name
:raises KiwiUriStyleUnknown: if the uri scheme can't be detected, is
unknown or it is inconsistent with the build environment
:param bool check_build_environment: specify if the uri translation
should depend on the environment the build is called in. As of
today this only effects the translation result if the image
build happens inside of the Open Build Service
:rtype: str
"""
uri = urlparse(self.uri)
if not uri.scheme:
raise KiwiUriStyleUnknown(
'URI scheme not detected {uri}'.format(uri=self.uri)
)
elif uri.scheme == 'obs':
if check_build_environment and Defaults.is_buildservice_worker():
return self._buildservice_path(
name=''.join([uri.netloc, uri.path]).replace(':/', ':'),
fragment=uri.fragment,
urischeme=uri.scheme
)
else:
return self._obs_project_download_link(
''.join([uri.netloc, uri.path]).replace(':/', ':')
)
elif uri.scheme == 'obsrepositories':
if not Defaults.is_buildservice_worker():
raise KiwiUriStyleUnknown(
'Only the buildservice can use the {0} schema'.format(
uri.scheme
)
)
return self._buildservice_path(
name=''.join([uri.netloc, uri.path]).replace(':/', ':'),
fragment=uri.fragment,
urischeme=uri.scheme
)
elif uri.scheme == 'dir':
return self._local_path(uri.path)
elif uri.scheme == 'file':
return self._local_path(uri.path)
elif uri.scheme == 'iso':
return self._iso_mount_path(uri.path)
elif uri.scheme.startswith('http') or uri.scheme == 'ftp':
return ''.join([uri.scheme, '://', uri.netloc, uri.path])
else:
raise KiwiUriStyleUnknown(
'URI schema %s not supported' % self.uri
)
示例2: _obs_project_download_link
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import is_buildservice_worker [as 别名]
def _obs_project_download_link(self, name):
name_parts = name.split(os.sep)
repository = name_parts.pop()
project = os.sep.join(name_parts)
try:
download_link = os.sep.join(
[
self.runtime_config.get_obs_download_server_url(),
project.replace(':', ':/'), repository
]
)
if not Defaults.is_buildservice_worker():
request = requests.get(download_link)
request.raise_for_status()
return request.url
else:
log.warning(
'Using {0} without location verification due to build '
'in isolated environment'.format(download_link)
)
return download_link
except Exception as e:
raise KiwiUriOpenError(
'{0}: {1}'.format(type(e).__name__, format(e))
)
示例3: is_remote
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import is_buildservice_worker [as 别名]
def is_remote(self):
"""
Check if URI is a remote or local location
:rtype: bool
"""
uri = urlparse(self.uri)
if not uri.scheme:
raise KiwiUriStyleUnknown(
'URI scheme not detected %s' % self.uri
)
if uri.scheme == 'obs' and Defaults.is_buildservice_worker():
return False
elif uri.scheme in self.remote_uri_types:
return True
elif uri.scheme in self.local_uri_type:
return False
else:
raise KiwiUriTypeUnknown(
'URI type %s unknown' % uri.scheme
)
示例4: create
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import is_buildservice_worker [as 别名]
def create(self):
"""
Create new system root directory
The method creates a temporary directory and initializes it
for the purpose of building a system image from it. This
includes the following setup:
* create static core device nodes
* create core system paths
On success the contents of the temporary location are
synced to the specified root_dir and the temporary location
will be deleted. That way we never work on an incomplete
initial setup
:raises KiwiRootInitCreationError: if the init creation fails
at some point
"""
root = mkdtemp(prefix='kiwi_root.')
Path.create(self.root_dir)
try:
self._create_base_directories(root)
self._create_base_links(root)
self._setup_config_templates(root)
data = DataSync(root + '/', self.root_dir)
data.sync_data(
options=['-a', '--ignore-existing']
)
if Defaults.is_buildservice_worker():
copy(
os.sep + Defaults.get_buildservice_env_name(),
self.root_dir)
except Exception as e:
self.delete()
raise KiwiRootInitCreationError(
'%s: %s' % (type(e).__name__, format(e))
)
finally:
rmtree(root, ignore_errors=True)
示例5: __init__
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import is_buildservice_worker [as 别名]
def __init__(self, root_dir, custom_args=None): # noqa: C901
self.root_dir = root_dir
self.oci_dir = None
self.oci_root_dir = None
self.container_name = 'kiwi-container'
self.container_tag = 'latest'
self.additional_tags = []
self.entry_command = []
self.entry_subcommand = []
self.maintainer = []
self.user = []
self.workingdir = []
self.expose_ports = []
self.volumes = []
self.environment = []
self.labels = []
self.runtime_config = RuntimeConfig()
if custom_args:
if 'container_name' in custom_args:
self.container_name = custom_args['container_name']
if 'container_tag' in custom_args:
self.container_tag = custom_args['container_tag']
if 'additional_tags' in custom_args:
self.additional_tags = custom_args['additional_tags']
if 'entry_command' in custom_args:
self.entry_command = custom_args['entry_command']
if 'entry_subcommand' in custom_args:
self.entry_subcommand = custom_args['entry_subcommand']
if 'maintainer' in custom_args:
self.maintainer = custom_args['maintainer']
if 'user' in custom_args:
self.user = custom_args['user']
if 'workingdir' in custom_args:
self.workingdir = custom_args['workingdir']
if 'expose_ports' in custom_args:
self.expose_ports = custom_args['expose_ports']
if 'volumes' in custom_args:
self.volumes = custom_args['volumes']
if 'environment' in custom_args:
self.environment = custom_args['environment']
if 'labels' in custom_args:
self.labels = custom_args['labels']
# for builds inside the buildservice we include a reference to the
# specific build. Thus disturl label only exists inside the
# buildservice.
if Defaults.is_buildservice_worker():
self._append_buildservice_disturl_label()
if not custom_args or 'container_name' not in custom_args:
log.info(
'No container configuration provided, '
'using default container name "kiwi-container:latest"'
)
if not self.entry_command and not self.entry_subcommand:
self.entry_subcommand = ['--config.cmd=/bin/bash']