Fix encoding bug when uploading mako template
at least it seems like that was a bug. hopefully i didn't just break other things
This commit is contained in:
parent
11db1579c4
commit
38b99cd817
|
@ -126,7 +126,7 @@ def upload_template(local_path, remote_path, owner='root:root', **kwargs):
|
||||||
sudo('chown {0} {1}'.format(owner, remote_path))
|
sudo('chown {0} {1}'.format(owner, remote_path))
|
||||||
|
|
||||||
|
|
||||||
def upload_mako_template(local_path, remote_path, context={}, **kwargs):
|
def upload_mako_template(local_path, remote_path, context={}, encoding='utf_8', **kwargs):
|
||||||
"""
|
"""
|
||||||
Render a local file as a Mako template, and upload the result to the server.
|
Render a local file as a Mako template, and upload the result to the server.
|
||||||
"""
|
"""
|
||||||
|
@ -135,7 +135,8 @@ def upload_mako_template(local_path, remote_path, context={}, **kwargs):
|
||||||
temp_dir = tempfile.mkdtemp(prefix='rattail-fabric.')
|
temp_dir = tempfile.mkdtemp(prefix='rattail-fabric.')
|
||||||
temp_path = os.path.join(temp_dir, os.path.basename(local_path))
|
temp_path = os.path.join(temp_dir, os.path.basename(local_path))
|
||||||
with open(temp_path, 'wb') as f:
|
with open(temp_path, 'wb') as f:
|
||||||
f.write(template.render(env=env, **context))
|
text = template.render(env=env, **context)
|
||||||
|
f.write(text.encode(encoding))
|
||||||
os.chmod(temp_path, os.stat(local_path).st_mode)
|
os.chmod(temp_path, os.stat(local_path).st_mode)
|
||||||
|
|
||||||
put(temp_path, remote_path, **kwargs)
|
put(temp_path, remote_path, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue