mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Move StringIO import to use six for salt.renderers.smtp_return.py
This commit is contained in:
parent
062ebba81c
commit
831d16ea5c
@ -1,11 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Import python libs
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
# Import python libs
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
# Import salt libs
|
# Import salt libs
|
||||||
|
import salt.ext.six as six
|
||||||
from salt.exceptions import SaltRenderError
|
from salt.exceptions import SaltRenderError
|
||||||
import salt.utils.templates
|
import salt.utils.templates
|
||||||
|
|
||||||
@ -33,4 +32,4 @@ def render(template_file,
|
|||||||
if not tmp_data.get('result', False):
|
if not tmp_data.get('result', False):
|
||||||
raise SaltRenderError(tmp_data.get('data',
|
raise SaltRenderError(tmp_data.get('data',
|
||||||
'Unknown render error in the wempy renderer'))
|
'Unknown render error in the wempy renderer'))
|
||||||
return StringIO(tmp_data['data'])
|
return six.StringIO.StringIO(tmp_data['data'])
|
||||||
|
@ -74,16 +74,16 @@ that prints any email it receives to the console.
|
|||||||
|
|
||||||
python -m smtpd -n -c DebuggingServer localhost:1025
|
python -m smtpd -n -c DebuggingServer localhost:1025
|
||||||
'''
|
'''
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
# Import python libs
|
# Import python libs
|
||||||
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import smtplib
|
import smtplib
|
||||||
import StringIO
|
|
||||||
from email.utils import formatdate
|
from email.utils import formatdate
|
||||||
|
|
||||||
# Import Salt libs
|
# Import Salt libs
|
||||||
|
import salt.ext.six as six
|
||||||
import salt.utils.jid
|
import salt.utils.jid
|
||||||
import salt.returners
|
import salt.returners
|
||||||
import salt.loader
|
import salt.loader
|
||||||
@ -159,7 +159,7 @@ def returner(ret):
|
|||||||
if field in ret:
|
if field in ret:
|
||||||
subject += ' {0}'.format(ret[field])
|
subject += ' {0}'.format(ret[field])
|
||||||
subject = compile_template(':string:', rend, renderer, blacklist, whitelist, input_data=subject, **ret)
|
subject = compile_template(':string:', rend, renderer, blacklist, whitelist, input_data=subject, **ret)
|
||||||
if isinstance(subject, StringIO.StringIO):
|
if isinstance(subject, six.StringIO.StringIO):
|
||||||
subject = subject.read()
|
subject = subject.read()
|
||||||
|
|
||||||
log.debug("smtp_return: Subject is '{0}'".format(subject))
|
log.debug("smtp_return: Subject is '{0}'".format(subject))
|
||||||
@ -187,7 +187,7 @@ def returner(ret):
|
|||||||
content = 'Encryption failed, the return data was not sent.\r\n\r\n{0}\r\n{1}'.format(
|
content = 'Encryption failed, the return data was not sent.\r\n\r\n{0}\r\n{1}'.format(
|
||||||
encrypted_data.status, encrypted_data.stderr)
|
encrypted_data.status, encrypted_data.stderr)
|
||||||
|
|
||||||
if isinstance(content, StringIO.StringIO):
|
if isinstance(content, six.StringIO.StringIO):
|
||||||
content = content.read()
|
content = content.read()
|
||||||
|
|
||||||
message = ('From: {0}\r\n'
|
message = ('From: {0}\r\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user