本文整理汇总了Python中snapcraft.meta.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_meta_with_declared_icon_and_setup
def test_create_meta_with_declared_icon_and_setup(self):
gui_path = os.path.join('setup', 'gui')
os.makedirs(gui_path)
icon_content = b'this is the icon'
with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
f.write(icon_content)
open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
self.config_data['icon'] = 'my-icon.png'
meta.create(self.config_data)
expected_icon = os.path.join(self.meta_dir, 'gui', 'icon.png')
self.assertTrue(os.path.exists(expected_icon),
'icon.png was not setup correctly')
with open(expected_icon, 'rb') as f:
self.assertEqual(f.read(), icon_content)
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
self.assertFalse('icon' in y,
'icon found in snap.yaml {}'.format(y))
开发者ID:dplanella,项目名称:snapcraft,代码行数:25,代码来源:test_meta.py
示例2: test_create_meta_with_declared_icon_and_setup
def test_create_meta_with_declared_icon_and_setup(self):
fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(fake_logger)
gui_path = os.path.join('setup', 'gui')
os.makedirs(gui_path)
icon_content = b'this is the icon'
with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
f.write(icon_content)
open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
self.config_data['icon'] = 'my-icon.png'
meta.create(self.config_data)
expected_icon = os.path.join(self.meta_dir, 'gui', 'icon.png')
self.assertTrue(os.path.exists(expected_icon),
'icon.png was not setup correctly')
with open(expected_icon, 'rb') as f:
self.assertEqual(f.read(), icon_content)
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
self.assertTrue(
"DEPRECATED: 'icon' defined in snapcraft.yaml"
in fake_logger.output, 'Missing deprecation message for icon')
with open(self.snap_yaml) as f:
y = yaml.load(f)
self.assertFalse('icon' in y,
'icon found in snap.yaml {}'.format(y))
开发者ID:fallen,项目名称:snapcraft,代码行数:32,代码来源:test_meta.py
示例3: test_create_meta_without_config
def test_create_meta_without_config(self, mock_the_open, mock_wrap_exe):
del self.config_data["config"]
meta.create(self.config_data, ["amd64"])
self.mock_makedirs.assert_called_once_with(self.meta_dir, exist_ok=True)
mock_the_open.assert_has_calls(self.expected_open_calls)
开发者ID:General-Beck,项目名称:snapcraft,代码行数:7,代码来源:test_meta.py
示例4: test_create_meta_with_app_with_security_policy
def test_create_meta_with_app_with_security_policy(self):
os.makedirs(self.snap_dir)
open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
open(os.path.join(os.curdir, 'stub-sec'), 'w').close()
self.config_data['apps'] = {
'app1': {
'command': 'app1.sh',
'uses': ['migration'],
},
}
self.config_data['uses'] = {
'migration': {
'type': 'migration-skill',
'security-policy': {
'apparmor': 'stub-sec',
'seccomp': 'stub-sec',
},
},
}
meta.create(self.config_data)
app1_wrapper_path = os.path.join(self.snap_dir, 'command-app1.wrapper')
self.assertTrue(
os.path.exists(app1_wrapper_path),
'the wrapper for app1 was not setup correctly')
sec_path = os.path.join(self.meta_dir, 'stub-sec')
self.assertTrue(
os.path.exists(sec_path),
'the security-policies for app1 were not setup correctly')
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
expected = {'architectures': ['amd64'],
'apps': {
'app1': {
'command': 'command-app1.wrapper',
'uses': ['migration'],
},
},
'uses': {
'migration': {
'type': 'migration-skill',
'security-policy': {
'apparmor': 'meta/stub-sec',
'seccomp': 'meta/stub-sec',
},
}
},
'description': 'my description',
'summary': 'my summary',
'name': 'my-package',
'version': '1.0'}
self.assertEqual(y, expected)
开发者ID:sergiusens,项目名称:snapcraft,代码行数:60,代码来源:test_meta.py
示例5: test_create_meta_with_vararg_config
def test_create_meta_with_vararg_config(self, mock_the_open,
mock_wrap_exe):
self.config_data['config'] = 'python3 my.py --config'
meta.create(self.config_data, ['amd64'])
self.mock_makedirs.assert_has_calls([
call(self.meta_dir, exist_ok=True),
call(self.hooks_dir),
])
self.mock_rename.assert_has_calls([
call(os.path.join(self.snap_dir, 'python3.wrapper'),
os.path.join(self.hooks_dir, 'config')),
])
mock_the_open.assert_has_calls(self.expected_open_calls)
mock_wrap_exe.assert_has_calls([
call(
'$SNAP_APP_PATH/bin/bash',
os.path.join(os.path.abspath(os.curdir),
'snap/bin/bash.wrapper'),
args=None, shebang=None,
),
call(
'$SNAP_APP_PATH/python3',
os.path.join(self.snap_dir, 'python3.wrapper'),
args=['my.py', '--config'], shebang=None,
),
])
开发者ID:kightlygeorge,项目名称:snapcraft,代码行数:30,代码来源:test_meta.py
示例6: test_create_meta
def test_create_meta(self, mock_the_open, mock_wrap_exe):
meta.create(self.config_data, ['amd64'])
self.mock_makedirs.assert_has_calls([
call(self.meta_dir, exist_ok=True),
call(self.hooks_dir),
])
self.mock_rename.assert_has_calls([
call(os.path.join(self.snap_dir, 'bin', 'config.wrapper'),
os.path.join(self.hooks_dir, 'config')),
])
mock_the_open.assert_has_calls(self.expected_open_calls)
mock_wrap_exe.assert_has_calls([
call(
'$SNAP_APP_PATH/bin/bash',
os.path.join(self.snap_dir, 'bin', 'bash.wrapper'),
args=None, shebang=None
),
call(
'$SNAP_APP_PATH/bin/config',
os.path.join(self.snap_dir, 'bin', 'config.wrapper'),
args=[], shebang=None,
),
])
self.mock_copyfile.assert_has_calls([
call('my-icon.png', os.path.join(self.meta_dir,
'my-icon.png')),
call('file.apparmor', os.path.join(self.meta_dir,
'file.apparmor')),
call('file.seccomp', os.path.join(self.meta_dir,
'file.seccomp')),
])
开发者ID:kightlygeorge,项目名称:snapcraft,代码行数:34,代码来源:test_meta.py
示例7: test_create_meta_with_app
def test_create_meta_with_app(self):
os.makedirs(self.snap_dir)
open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
self.config_data['apps'] = {
'app1': {'command': 'app1.sh'},
}
meta.create(self.config_data)
app1_wrapper_path = os.path.join(self.snap_dir, 'command-app1.wrapper')
self.assertTrue(
os.path.exists(app1_wrapper_path),
'the wrapper for app1 was not setup correctly')
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
expected = {'architectures': ['amd64'],
'apps': {
'app1': {
'command': 'command-app1.wrapper',
},
},
'description': 'my description',
'summary': 'my summary',
'name': 'my-package',
'version': '1.0'}
self.assertEqual(y, expected)
开发者ID:sergiusens,项目名称:snapcraft,代码行数:32,代码来源:test_meta.py
示例8: test_create_meta_with_config
def test_create_meta_with_config(self):
os.makedirs(self.snap_dir)
open(os.path.join(self.snap_dir, 'config.sh'), 'w').close()
self.config_data['config'] = 'config.sh'
meta.create(self.config_data)
self.assertTrue(
os.path.exists(os.path.join(self.hooks_dir, 'config')),
'the config was not setup correctly')
开发者ID:sergiusens,项目名称:snapcraft,代码行数:10,代码来源:test_meta.py
示例9: snap
def snap(args):
cmd(args)
# This check is to support manual assembly.
if not os.path.exists(os.path.join(common.get_snapdir(), 'meta')):
arches = [snapcraft.common.get_arch(), ]
config = _load_config()
# FIXME this should be done in a more contained manner
common.env = config.snap_env()
meta.create(config.data, arches)
开发者ID:General-Beck,项目名称:snapcraft,代码行数:13,代码来源:cmds.py
示例10: snap
def snap(args):
cmd(args)
config = _load_config()
# TODO move all this to meta.create
if 'architectures' in config.data:
arches = config.data['architectures']
else:
arches = [snapcraft.common.get_arch(), ]
# FIXME this should be done in a more contained manner
common.env = config.snap_env()
meta.create(config.data, arches)
开发者ID:kightlygeorge,项目名称:snapcraft,代码行数:14,代码来源:cmds.py
示例11: test_create_no_change_if_not_migration_skill
def test_create_no_change_if_not_migration_skill(self):
os.makedirs(self.snap_dir)
open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
open(os.path.join(os.curdir, 'stub-sec'), 'w').close()
self.config_data['apps'] = {
'app1': {
'command': 'app1.sh',
'uses': ['migration'],
},
}
self.config_data['uses'] = {
'migration': {
'type': 'migration-skillz',
'security-policy': {
'apparmor': 'stub-sec',
'seccomp': 'stub-sec',
},
},
}
meta.create(self.config_data)
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
expected = {'architectures': ['amd64'],
'apps': {
'app1': {
'command': 'command-app1.wrapper',
'uses': ['migration'],
},
},
'uses': {
'migration': {
'type': 'migration-skillz',
'security-policy': {
'apparmor': 'stub-sec',
'seccomp': 'stub-sec',
},
}
},
'description': 'my description',
'summary': 'my summary',
'name': 'my-package',
'version': '1.0'}
self.assertEqual(y, expected)
开发者ID:sergiusens,项目名称:snapcraft,代码行数:50,代码来源:test_meta.py
示例12: test_create_meta_with_declared_icon_and_setup_ran_twice_ok
def test_create_meta_with_declared_icon_and_setup_ran_twice_ok(self):
gui_path = os.path.join('setup', 'gui')
os.makedirs(gui_path)
icon_content = b'this is the icon'
with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
f.write(icon_content)
open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
self.config_data['icon'] = 'my-icon.png'
meta.create(self.config_data)
# Running again should be good
meta.create(self.config_data)
开发者ID:fallen,项目名称:snapcraft,代码行数:14,代码来源:test_meta.py
示例13: test_create_meta_with_vararg_config
def test_create_meta_with_vararg_config(self, mock_the_open, mock_wrap_exe):
self.config_data["config"] = "python3 my.py --config"
meta.create(self.config_data, ["amd64"])
self.mock_makedirs.assert_has_calls([call(self.meta_dir, exist_ok=True), call(self.hooks_dir)])
mock_the_open.assert_has_calls(self.expected_open_calls)
mock_wrap_exe.assert_has_calls(
[
call("$SNAP_APP_PATH/bin/bash", os.path.join(os.path.abspath(os.curdir), "snap/bin/bash.wrapper")),
call(
"python3", os.path.join(self.hooks_dir, "config"), args=["my.py", "--config"], cwd="$SNAP_APP_PATH"
),
]
)
开发者ID:General-Beck,项目名称:snapcraft,代码行数:16,代码来源:test_meta.py
示例14: test_create_meta_with_license
def test_create_meta_with_license(self, mock_the_open, mock_wrap_exe):
self.config_data.pop('config')
self.config_data['license'] = 'LICENSE'
meta.create(self.config_data)
self.mock_makedirs.assert_has_calls([
call(self.meta_dir, exist_ok=True),
call(self.hooks_dir),
])
self.mock_rename.assert_not_called()
mock_the_open.assert_has_calls(self.expected_open_calls)
self.mock_copyfile.assert_any_call(
'LICENSE', os.path.join(self.hooks_dir, 'license'))
开发者ID:earnubs,项目名称:snapcraft,代码行数:16,代码来源:test_meta.py
示例15: test_create_meta
def test_create_meta(self):
meta.create(self.config_data)
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
expected = {'architectures': ['amd64'],
'description': 'my description',
'summary': 'my summary',
'name': 'my-package',
'version': '1.0'}
self.assertEqual(y, expected)
开发者ID:sergiusens,项目名称:snapcraft,代码行数:16,代码来源:test_meta.py
示例16: test_create_meta_with_icon
def test_create_meta_with_icon(self):
open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
self.config_data['icon'] = 'my-icon.png'
meta.create(self.config_data)
self.assertTrue(
os.path.exists(os.path.join(self.meta_dir, 'icon.png')),
'icon.png was not setup correctly')
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
self.assertFalse('icon' in y,
'icon found in snap.yaml {}'.format(y))
开发者ID:sergiusens,项目名称:snapcraft,代码行数:17,代码来源:test_meta.py
示例17: test_create_meta_with_license
def test_create_meta_with_license(self):
open(os.path.join(os.curdir, 'LICENSE'), 'w').close()
self.config_data['license'] = 'LICENSE'
meta.create(self.config_data)
self.assertTrue(
os.path.exists(os.path.join(self.meta_dir, 'license.txt')),
'license.txt was not setup correctly')
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
self.assertFalse('license' in y,
'license found in snap.yaml {}'.format(y))
开发者ID:sergiusens,项目名称:snapcraft,代码行数:17,代码来源:test_meta.py
示例18: test_create_meta_with_config_with_args
def test_create_meta_with_config_with_args(self):
os.makedirs(self.snap_dir)
open(os.path.join(self.snap_dir, 'config.sh'), 'w').close()
self.config_data['config'] = 'config.sh something'
meta.create(self.config_data)
config_hook = os.path.join(self.hooks_dir, 'config')
self.assertTrue(
os.path.exists(config_hook), 'the config was not setup correctly')
with open(config_hook) as f:
config_wrapper = f.readlines()
expected_wrapper = [
'#!/bin/sh\n', '\n', '\n',
'exec "$SNAP/config.sh" something $*\n']
self.assertEqual(config_wrapper, expected_wrapper)
开发者ID:sergiusens,项目名称:snapcraft,代码行数:18,代码来源:test_meta.py
示例19: test_create_meta
def test_create_meta(self, mock_the_open, mock_wrap_exe):
meta.create(self.config_data, ["amd64"])
self.mock_makedirs.assert_has_calls([call(self.meta_dir, exist_ok=True), call(self.hooks_dir)])
mock_the_open.assert_has_calls(self.expected_open_calls)
mock_wrap_exe.assert_has_calls(
[
call("$SNAP_APP_PATH/bin/bash", os.path.join(os.path.abspath(os.curdir), "snap/bin/bash.wrapper")),
call("bin/config", os.path.join(self.hooks_dir, "config"), args=[], cwd="$SNAP_APP_PATH"),
]
)
self.mock_copyfile.assert_has_calls(
[
call("my-icon.png", os.path.join(self.meta_dir, "my-icon.png")),
call("file.apparmor", os.path.join(self.meta_dir, "file.apparmor")),
call("file.seccomp", os.path.join(self.meta_dir, "file.seccomp")),
]
)
开发者ID:General-Beck,项目名称:snapcraft,代码行数:19,代码来源:test_meta.py
示例20: test_create_meta_with_license_in_setup
def test_create_meta_with_license_in_setup(self):
os.mkdir('setup')
license_text = 'this is the license'
with open(os.path.join('setup', 'license.txt'), 'w') as f:
f.write(license_text)
meta.create(self.config_data)
expected_license = os.path.join(self.meta_dir, 'license.txt')
self.assertTrue(os.path.exists(expected_license),
'license.txt was not setup correctly')
with open(expected_license) as f:
self.assertEqual(f.read(), license_text)
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
y = yaml.load(f)
self.assertFalse('license' in y,
'license found in snap.yaml {}'.format(y))
开发者ID:dplanella,项目名称:snapcraft,代码行数:20,代码来源:test_meta.py
注:本文中的snapcraft.meta.create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论