本文整理汇总了Python中snapcraft.internal.lifecycle.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dirty_stage_reprimes
def test_dirty_stage_reprimes(self):
self.make_snapcraft_yaml(
textwrap.dedent("""\
parts:
part1:
plugin: nil
"""))
# Strip it.
lifecycle.execute('prime', self.project_options)
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
def _fake_dirty_report(self, step):
if step == 'stage':
return pluginhandler.DirtyReport({'foo'}, {'bar'})
return None
# Should automatically clean and re-stage if that step is dirty
# for the part.
with mock.patch.object(pluginhandler.PluginHandler, 'get_dirty_report',
_fake_dirty_report):
lifecycle.execute('prime', self.project_options)
self.assertThat(
self.fake_logger.output, Equals(
'Skipping pull part1 (already ran)\n'
'Skipping build part1 (already ran)\n'
'Cleaning priming area for part1 (out of date)\n'
'Cleaning staging area for part1 (out of date)\n'
'Staging part1 \n'
'Priming part1 \n'))
开发者ID:cholcombe973,项目名称:snapcraft,代码行数:34,代码来源:test_lifecycle.py
示例2: run
def run(args, project_options): # noqa
lifecycle_command = _get_lifecycle_command(args)
argless_command = _get_command_from_arg(args)
if lifecycle_command:
lifecycle.execute(
lifecycle_command, project_options, args['<part>'])
elif argless_command:
argless_command()
elif args['clean']:
_run_clean(args, project_options)
elif args['cleanbuild']:
lifecycle.cleanbuild(project_options),
elif _is_store_command(args):
_run_store_command(args)
elif args['tour']:
_scaffold_examples(args['<directory>'] or _SNAPCRAFT_TOUR_DIR)
elif args['help']:
snapcraft.topic_help(args['<topic>'] or args['<plugin>'],
args['--devel'], args['topics'])
elif args['update']:
parts.update()
elif args['define']:
parts.define(args['<part-name>'])
elif args['search']:
parts.search(' '.join(args['<query>']))
else: # snap by default:
lifecycle.snap(project_options, args['<directory>'], args['--output'])
return project_options
开发者ID:cjwatson,项目名称:snapcraft,代码行数:29,代码来源:main.py
示例3: run
def run(args, project_options):
lifecycle_command = _get_lifecycle_command(args)
argless_command = _get_command_from_arg(args)
if lifecycle_command:
lifecycle.execute(
lifecycle_command, project_options, args['<part>'])
elif argless_command:
argless_command()
elif args['clean']:
step = args['--step']
if step == 'strip':
logger.warning('DEPRECATED: Use `prime` instead of `strip` '
'as the step to clean')
step = 'prime'
lifecycle.clean(project_options, args['<part>'], step)
elif args['upload']:
snapcraft.upload(args['<snap-file>'])
elif args['cleanbuild']:
lifecycle.cleanbuild(project_options),
# disable until the tour command is activated
# elif args['tour']:
# _scaffold_examples(args['<directory>'] or _SNAPCRAFT_TOUR_DIR)
elif args['help']:
snapcraft.topic_help(args['<topic>'] or args['<plugin>'],
args['--devel'], args['topics'])
else: # snap by default:
lifecycle.snap(project_options, args['<directory>'], args['--output'])
return project_options
开发者ID:didrocks,项目名称:snapcraft,代码行数:29,代码来源:main.py
示例4: test_prime_with_build_info_records_manifest
def test_prime_with_build_info_records_manifest(self):
self.useFixture(fixtures.EnvironmentVariable(
'SNAPCRAFT_BUILD_INFO', '1'))
self.make_snapcraft_yaml(
textwrap.dedent("""\
parts:
test-part:
plugin: nil
"""))
lifecycle.execute('prime', self.project_options)
expected = textwrap.dedent("""\
name: test
version: 0
summary: test
description: test
confinement: strict
grade: stable
parts:
test-part:
build-packages: []
installed-packages: []
installed-snaps: []
plugin: nil
prime: []
stage: []
stage-packages: []
uname: Linux test uname 4.10 x86_64
architectures: [{}]
build-packages: []
build-snaps: []
""".format(self.project_options.deb_arch))
self.assertThat(
os.path.join('prime', 'snap', 'manifest.yaml'),
FileContains(expected))
开发者ID:cholcombe973,项目名称:snapcraft,代码行数:35,代码来源:test_lifecycle.py
示例5: test_dirty_stage_part_with_unbuilt_dependent
def test_dirty_stage_part_with_unbuilt_dependent(self):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
part2:
plugin: nil
after: [part1]
""")
# Stage dependency (dependent is unbuilt)
lifecycle.execute('stage', self.project_options, part_names=['part1'])
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
def _fake_is_dirty(self, step):
return step == 'stage'
# Should automatically clean and re-stage if that step is dirty
# for the part.
with mock.patch.object(pluginhandler.PluginHandler, 'is_dirty',
_fake_is_dirty):
lifecycle.execute('stage', self.project_options,
part_names=['part1'])
self.assertEqual(
'Skipping pull part1 (already ran)\n'
'Skipping build part1 (already ran)\n'
'Skipping cleaning priming area for part1 (out of date) '
'(already clean)\n'
'Cleaning staging area for part1 (out of date)\n'
'Staging part1 \n',
self.fake_logger.output)
开发者ID:CSRedRat,项目名称:snapcraft,代码行数:34,代码来源:test_lifecycle.py
示例6: test_prime_with_build_info_records_snapcraft_yaml
def test_prime_with_build_info_records_snapcraft_yaml(self):
self.useFixture(fixtures.EnvironmentVariable(
'SNAPCRAFT_BUILD_INFO', '1'))
self.make_snapcraft_yaml(
textwrap.dedent("""\
parts:
test-part:
plugin: nil
"""),
snap_type='type: app')
lifecycle.execute('prime', self.project_options)
expected = textwrap.dedent("""\
name: test
version: 0
summary: test
description: test
confinement: strict
grade: stable
type: app
parts:
test-part:
plugin: nil
""")
self.assertThat(
os.path.join('prime', 'snap', 'snapcraft.yaml'),
FileContains(expected))
开发者ID:cholcombe973,项目名称:snapcraft,代码行数:30,代码来源:test_lifecycle.py
示例7: test_pull_is_dirty_if_target_arch_changes
def test_pull_is_dirty_if_target_arch_changes(
self, mock_install_build_packages, mock_enable_cross_compilation):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
""")
# Pull it with amd64
lifecycle.execute('pull', snapcraft.ProjectOptions(
target_deb_arch='amd64'))
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
# Pull it again with armhf. Should catch that the part needs to be
# re-pulled due to the change in target architecture and raise an
# error.
raised = self.assertRaises(
RuntimeError,
lifecycle.execute,
'pull', snapcraft.ProjectOptions(
target_deb_arch='armhf'))
self.assertEqual("Setting target machine to 'armhf'\n",
self.fake_logger.output)
self.assertEqual(
"The 'pull' step of 'part1' is out of date:\n\n"
"The 'deb_arch' project option appears to have changed.\n\n"
"In order to continue, please clean that part's 'pull' step "
"by running: snapcraft clean part1 -s pull\n",
str(raised))
开发者ID:josepht,项目名称:snapcraft,代码行数:33,代码来源:test_lifecycle.py
示例8: test_core_setup_if_docker_env
def test_core_setup_if_docker_env(self, dockerenv_fake, download_mock):
dockerenv_file = os.path.join(self.tempdir, "dockerenv")
os.makedirs(self.tempdir)
open(dockerenv_file, "w").close()
dockerenv_fake.return_value = dockerenv_file
project_config = self.make_snapcraft_project(confinement="classic")
core_snap = self.create_core_snap(project_config.project.deb_arch)
core_snap_hash = calculate_sha3_384(core_snap)
download_mock.return_value = core_snap_hash
self.tempdir_mock.side_effect = self._setup_tempdir_side_effect(core_snap)
lifecycle.execute(steps.PULL, project_config)
regex = (".*mkdir -p {}\nunsquashfs -d {} .*{}\n").format(
os.path.dirname(self.core_path), self.core_path, core_snap_hash
)
self.assertThat(
self.witness_path,
FileContains(matcher=MatchesRegex(regex, flags=re.DOTALL)),
)
download_mock.assert_called_once_with(
"core",
"stable",
os.path.join(self.tempdir, "core.snap"),
project_config.project.deb_arch,
"",
)
开发者ID:mvo5,项目名称:snapcraft,代码行数:29,代码来源:test_lifecycle.py
示例9: test_core_setup_with_env_var
def test_core_setup_with_env_var(self, download_mock):
self.useFixture(fixtures.EnvironmentVariable("SNAPCRAFT_SETUP_CORE", "1"))
project_config = self.make_snapcraft_project(confinement="classic")
core_snap = self.create_core_snap(project_config.project.deb_arch)
core_snap_hash = calculate_sha3_384(core_snap)
download_mock.return_value = core_snap_hash
self.tempdir_mock.side_effect = self._setup_tempdir_side_effect(core_snap)
lifecycle.execute(steps.PULL, project_config)
regex = (".*mkdir -p {}\nunsquashfs -d {} .*{}\n").format(
os.path.dirname(self.core_path), self.core_path, core_snap_hash
)
self.assertThat(
self.witness_path,
FileContains(matcher=MatchesRegex(regex, flags=re.DOTALL)),
)
download_mock.assert_called_once_with(
"core",
"stable",
os.path.join(self.tempdir, "core.snap"),
project_config.project.deb_arch,
"",
)
开发者ID:mvo5,项目名称:snapcraft,代码行数:26,代码来源:test_lifecycle.py
示例10: test_dirty_stage_restrips
def test_dirty_stage_restrips(self):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
""")
# Strip it.
lifecycle.execute('strip', self.project_options)
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
def _fake_is_dirty(self, step):
return step == 'stage'
# Should automatically clean and re-stage if that step is dirty
# for the part.
with mock.patch.object(pluginhandler.PluginHandler, 'is_dirty',
_fake_is_dirty):
lifecycle.execute('strip', self.project_options)
self.assertEqual(
'Skipping pull part1 (already ran)\n'
'Skipping build part1 (already ran)\n'
'Cleaning snapping area for part1 (out of date)\n'
'Cleaning staging area for part1 (out of date)\n'
'Staging part1 \n'
'Stripping part1 \n',
self.fake_logger.output)
开发者ID:0-T-0,项目名称:snapcraft,代码行数:30,代码来源:test_lifecycle.py
示例11: test_dirty_pull_raises
def test_dirty_pull_raises(self):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
""")
# Pull it.
lifecycle.execute('pull', self.project_options)
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
def _fake_is_dirty(self, step):
return step == 'pull'
# Should catch that the part needs to be re-pulled and raise an error.
with mock.patch.object(pluginhandler.PluginHandler, 'is_dirty',
_fake_is_dirty):
with self.assertRaises(RuntimeError) as raised:
lifecycle.execute('pull', self.project_options)
self.assertEqual('', self.fake_logger.output)
self.assertEqual(
"The 'pull' step of 'part1' is out of date. Please clean that "
"part's 'pull' step in order to rebuild", str(raised.exception))
开发者ID:0-T-0,项目名称:snapcraft,代码行数:27,代码来源:test_lifecycle.py
示例12: test_dependency_is_staged_when_required
def test_dependency_is_staged_when_required(self):
project_config = self.make_snapcraft_project(
textwrap.dedent(
"""\
parts:
part1:
plugin: nil
part2:
plugin: nil
after:
- part1
"""
)
)
lifecycle.execute(steps.PULL, project_config, part_names=["part2"])
self.assertThat(
self.fake_logger.output,
Equals(
"'part2' has dependencies that need to be staged: part1\n"
"Pulling part1 \n"
"Building part1 \n"
"Staging part1 \n"
"Pulling part2 \n"
),
)
开发者ID:mvo5,项目名称:snapcraft,代码行数:27,代码来源:test_lifecycle.py
示例13: test_prime_with_build_info_records_snapcraft_yaml
def test_prime_with_build_info_records_snapcraft_yaml(self):
self.useFixture(fixtures.EnvironmentVariable("SNAPCRAFT_BUILD_INFO", "1"))
project_config = self.make_snapcraft_project(
textwrap.dedent(
"""\
parts:
test-part:
plugin: nil
"""
),
snap_type="type: app",
)
lifecycle.execute(steps.PRIME, project_config)
expected = textwrap.dedent(
"""\
name: test
version: 0
summary: test
description: test
confinement: strict
grade: stable
type: app
parts:
test-part:
plugin: nil
"""
)
self.assertThat(
os.path.join(steps.PRIME.name, "snap", "snapcraft.yaml"),
FileContains(expected),
)
开发者ID:mvo5,项目名称:snapcraft,代码行数:35,代码来源:test_lifecycle.py
示例14: test_core_setup_skipped_if_not_classic
def test_core_setup_skipped_if_not_classic(self):
self.useFixture(fixtures.EnvironmentVariable("SNAPCRAFT_SETUP_CORE", "1"))
project_config = self.make_snapcraft_project(confinement="strict")
lifecycle.execute(steps.PULL, project_config)
self.assertThat(self.witness_path, Not(FileExists()))
开发者ID:mvo5,项目名称:snapcraft,代码行数:7,代码来源:test_lifecycle.py
示例15: test_dirty_pull_raises
def test_dirty_pull_raises(self):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
""")
# Pull it.
lifecycle.execute('pull', self.project_options)
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
def _fake_dirty_report(self, step):
if step == 'pull':
return pluginhandler.DirtyReport(set(), {'foo', 'bar'})
return None
# Should catch that the part needs to be re-pulled and raise an error.
with mock.patch.object(pluginhandler.PluginHandler, 'get_dirty_report',
_fake_dirty_report):
raised = self.assertRaises(
RuntimeError,
lifecycle.execute,
'pull', self.project_options)
self.assertEqual('', self.fake_logger.output)
self.assertEqual(
"The 'pull' step of 'part1' is out of date:\n\n"
"The 'bar' and 'foo' project options appear to have changed.\n\n"
"In order to continue, please clean that part's 'pull' step "
"by running: snapcraft clean part1 -s pull\n",
str(raised))
开发者ID:josepht,项目名称:snapcraft,代码行数:34,代码来源:test_lifecycle.py
示例16: test_no_exception_when_dependency_is_required_but_already_staged
def test_no_exception_when_dependency_is_required_but_already_staged(self):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
part2:
plugin: nil
after:
- part1
""")
def _fake_should_step_run(self, step, force=False):
return self.name != 'part1'
with mock.patch.object(pluginhandler.PluginHandler,
'should_step_run',
_fake_should_step_run):
lifecycle.execute('pull', self.project_options,
part_names=['part2'])
self.assertEqual(
'Skipping pull part1 (already ran)\n'
'Skipping build part1 (already ran)\n'
'Skipping stage part1 (already ran)\n'
'Skipping prime part1 (already ran)\n'
'Preparing to pull part2 \n'
'Pulling part2 \n',
self.fake_logger.output)
开发者ID:josepht,项目名称:snapcraft,代码行数:27,代码来源:test_lifecycle.py
示例17: test_dirty_build_raises
def test_dirty_build_raises(self):
self.make_snapcraft_yaml("""parts:
part1:
plugin: nil
""")
# Build it.
lifecycle.execute('build', self.project_options)
# Reset logging since we only care about the following
self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
def _fake_dirty_report(self, step):
if step == 'build':
return pluginhandler.DirtyReport({'foo', 'bar'}, set())
return None
# Should catch that the part needs to be rebuilt and raise an error.
with mock.patch.object(pluginhandler.PluginHandler, 'get_dirty_report',
_fake_dirty_report):
raised = self.assertRaises(
RuntimeError,
lifecycle.execute,
'build', self.project_options)
self.assertEqual(
'Skipping pull part1 (already ran)\n',
self.fake_logger.output)
self.assertEqual(
"The 'build' step of 'part1' is out of date:\n\n"
"The 'bar' and 'foo' part properties appear to have changed.\n\n"
"Please clean that part's 'build' step in order to continue",
str(raised))
开发者ID:3v1n0,项目名称:snapcraft,代码行数:35,代码来源:test_lifecycle.py
示例18: test_prime_with_image_info_records_manifest
def test_prime_with_image_info_records_manifest(self):
self.useFixture(fixtures.EnvironmentVariable("SNAPCRAFT_BUILD_INFO", "1"))
test_image_info = (
'{"architecture": "test-architecture", '
'"created_at": "test-created-at", '
'"fingerprint": "test-fingerprint"}'
)
self.useFixture(
fixtures.EnvironmentVariable("SNAPCRAFT_IMAGE_INFO", test_image_info)
)
project_config = self.make_snapcraft_project(
textwrap.dedent(
"""\
parts:
test-part:
plugin: nil
"""
)
)
lifecycle.execute(steps.PRIME, project_config)
expected = textwrap.dedent(
"""\
snapcraft-version: '3.0'
snapcraft-os-release-id: ubuntu
snapcraft-os-release-version-id: '16.04'
name: test
version: 0
summary: test
description: test
confinement: strict
grade: stable
parts:
test-part:
build-packages: []
installed-packages:
- patchelf=0.9
installed-snaps: []
plugin: nil
prime: []
stage: []
stage-packages: []
uname: Linux test uname 4.10 x86_64
architectures:
- {}
image-info:
architecture: test-architecture
created_at: test-created-at
fingerprint: test-fingerprint
build-packages: []
build-snaps: []
""".format(
project_config.project.deb_arch
)
)
self.assertThat(
os.path.join(steps.PRIME.name, "snap", "manifest.yaml"),
FileContains(expected),
)
开发者ID:mvo5,项目名称:snapcraft,代码行数:59,代码来源:test_lifecycle.py
示例19: test_prime_with_virtual_build_package
def test_prime_with_virtual_build_package(self, _):
self.useFixture(fixtures.EnvironmentVariable("SNAPCRAFT_BUILD_INFO", "1"))
self.fake_apt_cache.add_package(
fixture_setup.FakeAptCachePackage(
"test-provider-package",
"test-version",
provides=["test-virtual-package"],
)
)
project_config = self.make_snapcraft_project(
textwrap.dedent(
"""\
parts:
test-part:
plugin: nil
build-packages: ['test-virtual-package']
"""
)
)
lifecycle.execute(steps.PRIME, project_config)
expected = textwrap.dedent(
"""\
snapcraft-version: '3.0'
snapcraft-os-release-id: ubuntu
snapcraft-os-release-version-id: '16.04'
name: test
version: 0
summary: test
description: test
confinement: strict
grade: stable
parts:
test-part:
build-packages:
- test-virtual-package
installed-packages:
- patchelf=0.9
installed-snaps: []
plugin: nil
prime: []
stage: []
stage-packages: []
uname: Linux test uname 4.10 x86_64
architectures:
- {}
build-packages:
- test-provider-package=test-version
build-snaps: []
""".format(
project_config.project.deb_arch
)
)
self.assertThat(
os.path.join(steps.PRIME.name, "snap", "manifest.yaml"),
FileContains(expected),
)
开发者ID:mvo5,项目名称:snapcraft,代码行数:59,代码来源:test_lifecycle.py
示例20: test_core_setup_skipped_if_core_exists
def test_core_setup_skipped_if_core_exists(self):
os.makedirs(self.core_path)
open(os.path.join(self.core_path, 'fake-content'), 'w').close()
self._create_classic_confined_snapcraft_yaml()
lifecycle.execute('pull', self.project_options)
self.assertThat(self.witness_path, Not(FileExists()))
开发者ID:josepht,项目名称:snapcraft,代码行数:8,代码来源:test_lifecycle.py
注:本文中的snapcraft.internal.lifecycle.execute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论