Skip to content
Snippets Groups Projects
Verified Commit dfd1ab8f authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

replace os by pathlib

parent a59ad160
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,6 @@ Criticality: High ...@@ -5,8 +5,6 @@ Criticality: High
Tests that all webserver services (vhosts) are available and reachable. Tests that all webserver services (vhosts) are available and reachable.
""" """
import imp
import os
from pathlib import Path from pathlib import Path
import re import re
import requests import requests
...@@ -186,28 +184,24 @@ def main(): ...@@ -186,28 +184,24 @@ def main():
print("Check that nginx vhosts are well configured:") print("Check that nginx vhosts are well configured:")
# check that Nginx dir exists # check that Nginx dir exists
nginx_dir = "/etc/nginx/sites-enabled" nginx_dir = "/etc/nginx/sites-enabled"
if not os.path.exists(nginx_dir): if not Path(nginx_dir).exists():
u.error("nginx dir does not exists ('%s')." % nginx_dir) u.error("nginx dir does not exists ('%s')." % nginx_dir)
sys.exit(2) exit(2)
# check that Wowza is installed # check that Wowza is installed
wowza_dir = "/usr/local/WowzaStreamingEngine" wowza_dir = "/usr/local/WowzaStreamingEngine"
if not os.path.exists(wowza_dir): if not Path(wowza_dir).exists():
u.info("wowza is not installed ('%s' does not exist)." % wowza_dir) u.info("wowza is not installed ('%s' does not exist)." % wowza_dir)
wowza_dir = None wowza_dir = None
else: else:
u.info("wowza is installed, /streaming/ will be tested on mediaserver vhosts.") u.info("wowza is installed, /streaming/ will be tested on mediaserver vhosts.")
# get envsetup conf # get envsetup conf
conf = dict() conf = u.load_conf()
os.chdir(os.path.dirname(__file__))
if os.path.isfile("../utils.py"):
es_utils = imp.load_source("es_utils", "../utils.py")
conf = es_utils.load_conf()
# get celerity conf # get celerity conf
celerity_conf = "" celerity_conf = ""
if os.path.exists("/etc/celerity/config.py"): if Path("/etc/celerity/config.py").exists():
with open("/etc/celerity/config.py", "r") as fo: with open("/etc/celerity/config.py", "r") as fo:
celerity_conf = fo.read() celerity_conf = fo.read()
...@@ -236,12 +230,12 @@ def main(): ...@@ -236,12 +230,12 @@ def main():
errors += e errors += e
if errors: if errors:
sys.exit(1) exit(1)
elif warnings: elif warnings:
sys.exit(3) exit(3)
if not tested: if not tested:
u.error("no url found in nginx sites-enabled dir") u.error("no url found in nginx sites-enabled dir")
sys.exit(1) exit(1)
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment