Fix linter issues

This commit is contained in:
Daniel A. Wozniak 2019-04-21 22:43:15 +00:00
parent 0ea007de6f
commit cf88c27353
No known key found for this signature in database
GPG Key ID: 166B9D2C06C82D61
2 changed files with 10 additions and 4 deletions

View File

@ -172,7 +172,7 @@ def _parse_chattr_man(man):
''' '''
Parse the contents of a chattr man page to find the E2fsprogs version Parse the contents of a chattr man page to find the E2fsprogs version
''' '''
match = re.search('E2fsprogs version [0-9\.]+', man) match = re.search(r'E2fsprogs version [0-9\.]+', man)
if match: if match:
version = match.group().strip('E2fsprogs version ') version = match.group().strip('E2fsprogs version ')
else: else:
@ -608,7 +608,7 @@ def lsattr(path):
needed_version = salt.utils.versions.LooseVersion('1.41.12') needed_version = salt.utils.versions.LooseVersion('1.41.12')
chattr_version = salt.utils.versions.LooseVersion(_chattr_version()) chattr_version = salt.utils.versions.LooseVersion(_chattr_version())
# The version of chattr on Centos 6 does not support extended # The version of chattr on Centos 6 does not support extended
# attributes. # attributes.
if chattr_version > needed_version: if chattr_version > needed_version:
results[vals[1]] = re.findall(r"[aAcCdDeijPsStTu]", vals[0]) results[vals[1]] = re.findall(r"[aAcCdDeijPsStTu]", vals[0])
else: else:

View File

@ -2061,12 +2061,18 @@ class ChattrVersionTests(TestCase):
' CHATTR(1)' ' CHATTR(1)'
) )
def test_chattr_version(self): def test__parse_chattr_version(self):
'''
Validate we can parse the E2fsprogs version from the chattr man page
'''
man_out = dedent(self.CHATTR_MAN) man_out = dedent(self.CHATTR_MAN)
parsed_version = filemod._parse_chattr_man(man_out) parsed_version = filemod._parse_chattr_man(man_out)
assert parsed_version == '1.43.4', parsed_version assert parsed_version == '1.43.4', parsed_version
def test_chattr_version(self): def test__chattr_version(self):
'''
The _chattr_version method works
'''
with patch('subprocess.check_output', return_value=self.CHATTR_MAN): with patch('subprocess.check_output', return_value=self.CHATTR_MAN):
parsed_version = filemod._chattr_version() parsed_version = filemod._chattr_version()
assert parsed_version == '1.43.4', parsed_version assert parsed_version == '1.43.4', parsed_version