Make sure the email subject and body are strings

compile_template returns StringIO objects.
This commit is contained in:
Seth House 2016-03-04 14:33:42 -07:00
parent fc69d08e8e
commit 74563f17ed

View file

@ -151,19 +151,19 @@ def returner(ret):
for field in fields:
if field in ret:
subject += ' {0}'.format(ret[field])
subject = compile_template(':string:', rend, renderer, input_data=subject, **ret)
subject = compile_template(':string:', rend, renderer, input_data=subject, **ret).getvalue()
log.debug("smtp_return: Subject is '{0}'".format(subject))
template = _options.get('template')
if template:
content = compile_template(template, rend, renderer, **ret)
content = compile_template(template, rend, renderer, **ret).getvalue()
else:
template = ('id: {{id}}\r\n'
'function: {{fun}}\r\n'
'function args: {{fun_args}}\r\n'
'jid: {{jid}}\r\n'
'return: {{return}}\r\n')
content = compile_template(':string:', rend, renderer, input_data=template, **ret)
content = compile_template(':string:', rend, renderer, input_data=template, **ret).getvalue()
if HAS_GNUPG and gpgowner:
gpg = gnupg.GPG(gnupghome=os.path.expanduser('~{0}/.gnupg'.format(gpgowner)),