fix versionstring parsing
This commit is contained in:
parent
8df15a5595
commit
52dc918125
6
api.py
6
api.py
|
@ -4,6 +4,7 @@ import re
|
||||||
|
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
class EjabberdApi:
|
class EjabberdApi:
|
||||||
"""
|
"""
|
||||||
|
@ -31,17 +32,18 @@ class EjabberdApi:
|
||||||
@property
|
@property
|
||||||
def verstring(self):
|
def verstring(self):
|
||||||
if self._login is not None:
|
if self._login is not None:
|
||||||
ver_str = re.compile('([1-9][0-9.]*)')
|
ver_str = re.compile('([1-9][0-9.]+)')
|
||||||
status = self.cmd('status', {})
|
status = self.cmd('status', {})
|
||||||
|
|
||||||
# matches
|
# matches
|
||||||
try:
|
try:
|
||||||
tmp = ver_str.findall(status)[0]
|
tmp = ver_str.findall(status)[1]
|
||||||
# raise SystemExit code 17 if no status message is received
|
# raise SystemExit code 17 if no status message is received
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise SystemExit(17)
|
raise SystemExit(17)
|
||||||
|
|
||||||
# return parsed version string
|
# return parsed version string
|
||||||
|
logging.debug(f"fetch version: {tmp}")
|
||||||
return version.parse(tmp)
|
return version.parse(tmp)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue