mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Use a proper subprocess for conf test instead of dirty os.system + store errors if there are
This commit is contained in:
parent
5d46f3ef88
commit
acba0c4a10
1 changed files with 11 additions and 2 deletions
|
@ -334,8 +334,17 @@ def service_status(names=[]):
|
||||||
|
|
||||||
# 'test-status' is an optional field to test the status of the service using a custom command
|
# 'test-status' is an optional field to test the status of the service using a custom command
|
||||||
if "test-conf" in services[name]:
|
if "test-conf" in services[name]:
|
||||||
conf = os.system(services[name]["test-conf"] + " &>/dev/null")
|
p = subprocess.Popen(services[name]["test-conf"],
|
||||||
result[name]["configuration"] = "valid" if conf == 0 else "broken"
|
shell=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
out, _ = p.communicate()
|
||||||
|
if p.returncode == 0:
|
||||||
|
result[name]["configuration"] = "valid"
|
||||||
|
else:
|
||||||
|
result[name]["configuration"] = "broken"
|
||||||
|
result[name]["configuration-details"] = out.strip().split("\n")
|
||||||
|
|
||||||
if len(names) == 1:
|
if len(names) == 1:
|
||||||
return result[names[0]]
|
return result[names[0]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue