本文整理汇总了Python中snapcraft.meta.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
示例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))
示例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)
示例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)
示例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,
),
])
示例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')),
])
示例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)
示例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')
示例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)
示例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)
示例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)
示例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)
示例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"
),
]
)
示例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'))
示例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)