Switch open() for salt.utils.fopen()

This commit is contained in:
Pedro Algarvio 2014-11-26 19:17:33 +00:00
parent b2e0c9905d
commit d523a089af

View File

@ -43,6 +43,9 @@ from __future__ import with_statement, print_function
# Import python libs
import os.path
# Import Salt libs
import salt.utils
def __virtual__():
return 'apache.config' in __salt__
@ -57,7 +60,7 @@ def configfile(name, config):
configs = __salt__['apache.config'](name, config, edit=False)
current_configs = ''
if os.path.exists(name):
with open(name) as config_file:
with salt.utils.fopen(name) as config_file:
current_configs = config_file.read()
if configs == current_configs.strip():
@ -74,7 +77,7 @@ def configfile(name, config):
return ret
try:
with open(name, 'w') as config_file:
with salt.utils.fopen(name, 'w') as config_file:
print(configs, file=config_file)
ret['changes'] = {
'old': current_configs,