mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Switch open()
for salt.utils.fopen()
This commit is contained in:
parent
b2e0c9905d
commit
d523a089af
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user