only run gencode scripts if they exist

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-10-13 16:56:03 +02:00
parent d37ca88752
commit 773d325afa

View file

@ -95,15 +95,16 @@ class Code(object):
def _run_gencode(self, cdist_object, which): def _run_gencode(self, cdist_object, which):
cdist_type = cdist_object.type cdist_type = cdist_object.type
script = os.path.join(self.local.type_path, getattr(cdist_type, 'gencode_%s_path' % which)) script = os.path.join(self.local.type_path, getattr(cdist_type, 'gencode_%s_path' % which))
env = os.environ.copy() if os.path.isfile(script):
env.update(self.env) env = os.environ.copy()
env.update({ env.update(self.env)
'__type': cdist_object.type.absolute_path, env.update({
'__object': cdist_object.absolute_path, '__type': cdist_object.type.absolute_path,
'__object_id': cdist_object.object_id, '__object': cdist_object.absolute_path,
'__object_fq': cdist_object.path, '__object_id': cdist_object.object_id,
}) '__object_fq': cdist_object.path,
return self.local.run_script(script, env=env) })
return self.local.run_script(script, env=env)
def run_gencode_local(self, cdist_object): def run_gencode_local(self, cdist_object):
"""Run the gencode-local script for the given cdist object.""" """Run the gencode-local script for the given cdist object."""