Update wrapper recipe to make it simpler and more dev-friendly.

parent d0aebea0
......@@ -30,25 +30,32 @@ import shlex
from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe):
def install(self):
command_line = shlex.split(self.options['command-line'])
wrapper_path = self.options['wrapper-path']
wait_files = self.options.get('wait-for-files')
environment = self.options.get('environment')
if not wait_files and not environment:
# Create a simple wrapper as shell script
return [self.createWrapper(
name=wrapper_path,
command=command_line[0],
parameters=command_line[1:],
)]
# More complex needs: create a Python script as wrapper
if wait_files is not None:
wait_files = [filename.strip() for filename in wait_files.split()
if filename.strip()]
environment = self.options.get('environment')
if environment is not None:
environment = dict((k.strip(), v.strip()) for k, v in [
line.split('=')
for line in environment.split('\n')
])
return [self.createPythonScript(
self.options['output'],
wrapper_path,
'slapos.recipe.librecipe.execute.generic_exec',
(command_line, wait_files, environment,),
)]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment