Tweak how 'env' is added to context for mako template upload

This commit is contained in:
Lance Edgar 2019-02-19 21:44:26 -06:00
parent f20c7e4b52
commit 2393374923

View file

@ -137,10 +137,14 @@ def upload_mako_template(local_path, remote_path, context={}, encoding='utf_8',
"""
template = Template(filename=local_path)
# make copy of context; add env to it
context = dict(context)
context['env'] = env
temp_dir = tempfile.mkdtemp(prefix='rattail-fabric.')
temp_path = os.path.join(temp_dir, os.path.basename(local_path))
with open(temp_path, 'wb') as f:
text = template.render(env=env, **context)
text = template.render(**context)
f.write(text.encode(encoding))
os.chmod(temp_path, os.stat(local_path).st_mode)