Move StringIO import to use six for salt.renderers.smtp_return.py

This commit is contained in:
rallytime 2016-07-07 19:10:36 -06:00
parent 062ebba81c
commit 831d16ea5c
2 changed files with 7 additions and 8 deletions

View File

@ -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'])

View File

@ -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'