salt.modules.upstart: fix lint errors

This commit is contained in:
Cameron Norman 2015-06-17 10:18:35 -07:00
parent 03278bd973
commit 26e406a5ce

View File

@ -172,12 +172,13 @@ def _upstart_is_disabled(name):
in /etc/init/[name].conf. in /etc/init/[name].conf.
''' '''
files = ['/etc/init/{0}.conf'.format(name), '/etc/init/{0}.override'.format(name)] files = ['/etc/init/{0}.conf'.format(name), '/etc/init/{0}.override'.format(name)]
for file_name in filter(os.path.isfile, files): for file_name in itertools.ifilter(os.path.isfile, files):
with salt.utils.fopen(file_name) as fp_: with salt.utils.fopen(file_name) as fp_:
if re.search('^\s*manual', fp_.read(), re.MULTILINE): if re.search(r'^\s*manual', fp_.read(), re.MULTILINE):
return True return True
return False return False
def _upstart_is_enabled(name): def _upstart_is_enabled(name):
''' '''
Assume that if an Upstart service is not disabled then it must be Assume that if an Upstart service is not disabled then it must be
@ -457,9 +458,9 @@ def _upstart_enable(name):
return _upstart_is_enabled(name) return _upstart_is_enabled(name)
override = '/etc/init/{0}.override'.format(name) override = '/etc/init/{0}.override'.format(name)
files = ['/etc/init/{0}.conf'.format(name), override] files = ['/etc/init/{0}.conf'.format(name), override]
for file_name in filter(os.path.isfile, files): for file_name in itertools.ifilter(os.path.isfile, files):
with salt.utils.fopen(file_name, 'r+') as fp_: with salt.utils.fopen(file_name, 'r+') as fp_:
new_text = re.sub('^\s*manual\n?', '', fp_.read(), 0, re.MULTILINE) new_text = re.sub(r'^\s*manual\n?', '', fp_.read(), 0, re.MULTILINE)
fp_.seek(0) fp_.seek(0)
fp_.write(new_text) fp_.write(new_text)
fp_.truncate() fp_.truncate()