jsondump recipe: use GenericBaseRecipe.

parent e18d01ba
from slapos.recipe.librecipe import GenericBaseRecipe
import json import json
import os import os
class Recipe(object): class Recipe(GenericBaseRecipe):
def __init__(self, buildout, name, options):
def install(self):
parameter_dict = { parameter_dict = {
key: value key: value
for key, value in options.items() for key, value in self.options.items()
if key not in ['json-output', 'recipe'] if key not in ['json-output', 'recipe']
} }
self._json_output = options['json-output'] with os.fdopen(os.open(self.options['json-output'], os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
with os.fdopen(os.open(self._json_output, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True)) fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True))
fout.close()
def install(self): return [self.options['json-output']]
return [self._json_output]
update = install update = install
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