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