MCPcopy Create free account
hub / github.com/saltstack/salt / _render

Function _render

salt/modules/cmdmod.py:165–180  ·  view source on GitHub ↗
(contents)

Source from the content-addressed store, hash-verified

163 kwargs["saltenv"] = saltenv
164
165 def _render(contents):
166 # write out path to temp file
167 tmp_path_fn = salt.utils.files.mkstemp()
168 with salt.utils.files.fopen(tmp_path_fn, "w+") as fp_:
169 fp_.write(salt.utils.stringutils.to_str(contents))
170 data = salt.utils.templates.TEMPLATE_REGISTRY[template](
171 tmp_path_fn, to_str=True, **kwargs
172 )
173 salt.utils.files.safe_rm(tmp_path_fn)
174 if not data["result"]:
175 # Failed to render the template
176 raise CommandExecutionError(
177 "Failed to execute cmd with error: {}".format(data["data"])
178 )
179 else:
180 return data["data"]
181
182 cmd = _render(cmd)
183 cwd = _render(cwd)

Callers 1

_render_cmdFunction · 0.70

Calls 3

formatMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected