mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix retrieve systemd version using regex
Fixes #51745 Signed-off-by: Jordan Jacobelli <jordan@cri.epita.fr>
This commit is contained in:
parent
f867e6e565
commit
94809d0a17
1 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,7 @@ Contains systemd related help files
|
|||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
# Import Salt libs
|
||||
|
@ -65,8 +66,8 @@ def version(context=None):
|
|||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
|
||||
outstr = salt.utils.stringutils.to_str(stdout)
|
||||
try:
|
||||
ret = int(outstr.splitlines()[0].split()[-1])
|
||||
except (IndexError, ValueError):
|
||||
ret = int(re.search(r'\w+ ([0-9]+)', outstr.splitlines()[0]).group(1))
|
||||
except (AttributeError, IndexError, ValueError):
|
||||
log.error(
|
||||
'Unable to determine systemd version from systemctl '
|
||||
'--version, output follows:\n%s', outstr
|
||||
|
|
Loading…
Add table
Reference in a new issue