本文整理汇总了Python中snapcraft.internal.meta.create_snap_packaging函数的典型用法代码示例。如果您正苦于以下问题:Python create_snap_packaging函数的具体用法?Python create_snap_packaging怎么用?Python create_snap_packaging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_snap_packaging函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
setup_icon_content = b'setup icon'
with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
f.write(setup_icon_content)
declared_icon_content = b'declared icon'
with open('my-icon.png', 'wb') as f:
f.write(declared_icon_content)
self.config_data['icon'] = 'my-icon.png'
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
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(), declared_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'
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
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_gadget_meta_with_missing_gadget_yaml_raises_error
def test_create_gadget_meta_with_missing_gadget_yaml_raises_error(self):
self.config_data['type'] = 'gadget'
with self.assertRaises(MissingGadgetError):
create_snap_packaging(self.config_data,
self.snap_dir,
self.parts_dir)
示例4: generate_meta_yaml
def generate_meta_yaml(self):
create_snap_packaging(self.config_data, self.project_options)
self.assertTrue(
os.path.exists(self.snap_yaml), 'snap.yaml was not created')
with open(self.snap_yaml) as f:
return yaml.load(f)
示例5: _create_meta
def _create_meta(self, step, part_names):
if step == steps.PRIME and part_names == self.config.part_names:
common.env = self.config.snap_env()
meta.create_snap_packaging(
self.config.data,
self.config.parts,
self.project,
self.config.validator.schema,
)
示例6: test_create_gadget_meta_with_gadget_yaml
def test_create_gadget_meta_with_gadget_yaml(self):
gadget_yaml = 'stub entry: stub value'
_create_file('gadget.yaml', content=gadget_yaml)
self.config_data['type'] = 'gadget'
create_snap_packaging(self.config_data, self.project_options, 'dummy')
expected_gadget = os.path.join(self.meta_dir, 'gadget.yaml')
self.assertTrue(os.path.exists(expected_gadget))
self.assertThat(expected_gadget, FileContains(gadget_yaml))
示例7: test_create_meta_with_app
def test_create_meta_with_app(self):
os.mkdir(self.snap_dir)
open(os.path.join(self.snap_dir, 'app.sh'), 'w').close()
self.config_data['apps'] = {
'app1': {'command': 'app.sh'},
'app2': {'command': 'app.sh', 'plugs': ['network']},
'app3': {'command': 'app.sh', 'plugs': ['network-server']}
}
self.config_data['plugs'] = {
'network-server': {'interface': 'network-bind'}}
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
for app in ['app1', 'app2', 'app3']:
app_wrapper_path = os.path.join(
self.snap_dir, 'command-{}.wrapper'.format(app))
self.assertTrue(
os.path.exists(app_wrapper_path),
'the wrapper for {!r} was not setup correctly'.format(app))
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',
},
'app2': {
'command': 'command-app2.wrapper',
'plugs': ['network'],
},
'app3': {
'command': 'command-app3.wrapper',
'plugs': ['network-server'],
},
},
'description': 'my description',
'summary': 'my summary',
'name': 'my-package',
'version': '1.0',
'plugs': {
'network-server': {
'interface': 'network-bind',
}
}
}
self.assertEqual(y, expected)
示例8: test_create_gadget_meta_with_gadget_yaml
def test_create_gadget_meta_with_gadget_yaml(self):
gadget_yaml = 'stub entry: stub value'
with open(os.path.join('gadget.yaml'), 'w') as f:
f.write(gadget_yaml)
self.config_data['type'] = 'gadget'
create_snap_packaging(self.config_data, self.project_options)
expected_gadget = os.path.join(self.meta_dir, 'gadget.yaml')
self.assertTrue(os.path.exists(expected_gadget))
with open(expected_gadget) as f:
self.assertEqual(f.read(), gadget_yaml)
示例9: 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 = 'setup icon'
_create_file(os.path.join(gui_path, 'icon.png'), content=icon_content)
_create_file('my-icon.png')
self.config_data['icon'] = 'my-icon.png'
create_snap_packaging(self.config_data, self.project_options, 'dummy')
# Running again should be good
create_snap_packaging(self.config_data, self.project_options, 'dummy')
示例10: test_create_meta_with_epoch
def test_create_meta_with_epoch(self):
self.config_data['epoch'] = '1*'
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
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.assertTrue(
'epoch' in y,
'Expected "epoch" property to be copied into snap.yaml')
self.assertEqual(y['epoch'], '1*')
示例11: 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'
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
# Running again should be good
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
示例12: test_create_meta_with_assumes
def test_create_meta_with_assumes(self):
self.config_data['assumes'] = ['feature1', 'feature2']
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
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.assertTrue(
'assumes' in y,
'Expected "assumes" property to be copied into snap.yaml')
self.assertEqual(y['assumes'], ['feature1', 'feature2'])
示例13: test_create_meta
def test_create_meta(self):
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
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)
示例14: test_create_meta_with_declared_license
def test_create_meta_with_declared_license(self):
open(os.path.join(os.curdir, 'LICENSE'), 'w').close()
self.config_data['license'] = 'LICENSE'
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
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))
示例15: test_create_meta_with_declared_icon
def test_create_meta_with_declared_icon(self):
open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
self.config_data['icon'] = 'my-icon.png'
create_snap_packaging(self.config_data, self.snap_dir, self.parts_dir)
self.assertTrue(
os.path.exists(os.path.join(self.meta_dir, 'gui', '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))