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

use f-strings

parent 6b71b6a9
No related branches found
No related tags found
No related merge requests found
......@@ -91,11 +91,11 @@ def test_vhost(
name = nginx_file.name
for port, proto in ports_info or [(80, False)]:
for domain in domains or ["localhost"]:
url = "%s://%s:%s" % (proto, domain, port)
u.info("- testing url '%s' from %s" % (url, name))
url = f"{proto}://{domain}:{port}"
u.info(f"- testing url '{url}' from {name}")
if name.startswith("mediaserver") and not tested:
if not re.search(r"https?://%s" % domain, celerity_conf):
u.warning("url '%s' not found in celerity conf" % url)
u.warning(f"url '{url}' not found in celerity conf")
warnings += 1
# test domain IP
ip_error = None
......@@ -103,19 +103,19 @@ def test_vhost(
try:
ip = socket.gethostbyname(domain)
except Exception as e:
ip_error = "domain: not resolved %s" % e
ip_error = f"domain: not resolved {e}"
else:
if ip != "127.0.0.1":
ip_warning = "domain: resolve to %s instead of 127.0.0.1" % ip
ip_warning = f"domain: resolve to {ip} instead of 127.0.0.1"
if ip_error:
if resolution_ignored and domain in resolution_ignored:
u.info("%s (ignored)" % ip_error)
u.info(f"{ip_error} (ignored)")
ip_error = None
else:
u.error(ip_error)
elif ip_warning:
if resolution_ignored and domain in resolution_ignored:
u.info("%s (ignored)" % ip_warning)
u.info(f"{ip_warning} (ignored)")
ip_warning = None
else:
u.warning(ip_warning)
......@@ -139,14 +139,14 @@ def test_vhost(
or domain == "localhost"
and code not in (200, 401, 403, 404)
):
u.error("status: %s, %sms" % (code, req_time))
u.error(f"status: {code}, {req_time}ms")
req_error = True
else:
if req_time > 10000:
u.warning("status: %s, %sms" % (code, req_time))
u.warning(f"status: {code}, {req_time}ms")
warnings += 1
else:
u.success("status: %s, %sms" % (code, req_time))
u.success(f"status: {code}, {req_time}ms")
if "mediaserver" in name and wowza_dir:
# test /streaming url
try:
......@@ -163,13 +163,13 @@ def test_vhost(
else:
code = req.status_code
if code != 200:
u.error("streaming: %s, %sms" % (code, req_time))
u.error(f"streaming: {code}, {req_time}ms")
req_error = True
elif req_time > 10000:
u.warning("streaming: %s, %sms" % (code, req_time))
u.warning(f"streaming: {code}, {req_time}ms")
warnings += 1
else:
u.success("streaming: %s, %sms" % (code, req_time))
u.success(f"streaming: {code}, {req_time}ms")
tested += 1
if ip_warning:
......@@ -185,13 +185,13 @@ def main():
# check that Nginx dir exists
nginx_dir = "/etc/nginx/sites-enabled"
if not Path(nginx_dir).exists():
u.info("nginx dir does not exists ('%s'), test skipped." % nginx_dir)
u.info(f"nginx dir does not exists ('{nginx_dir}'), test skipped.")
exit(2)
# check that Wowza is installed
wowza_dir = "/usr/local/WowzaStreamingEngine"
if not Path(wowza_dir).exists():
u.info("wowza is not installed ('%s' does not exist)." % wowza_dir)
u.info(f"wowza is not installed ('wowza_dir' does not exist).")
wowza_dir = None
else:
u.info("wowza is installed, /streaming/ will be tested on mediaserver vhosts.")
......
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