From 2d024557a5784de37534cbca1461dbdc90ec68ca Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 30 Jan 2023 17:34:24 +0000 Subject: [PATCH] [CI] Format code with Black --- src/diagnosers/10-ip.py | 20 ++++++++++++++++---- src/diagnosers/14-ports.py | 10 ++++++++-- src/diagnosers/21-web.py | 18 ++++++++++++++---- src/diagnosers/24-mail.py | 8 ++++++-- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/diagnosers/10-ip.py b/src/diagnosers/10-ip.py index 6b35731a0..a4df11dde 100644 --- a/src/diagnosers/10-ip.py +++ b/src/diagnosers/10-ip.py @@ -120,12 +120,16 @@ class MyDiagnoser(Diagnoser): return local_ip def is_ipvx_important(x): - return settings_get("misc.network.dns_exposure") in ["both", "ipv"+str(x)] + return settings_get("misc.network.dns_exposure") in ["both", "ipv" + str(x)] yield dict( meta={"test": "ipv4"}, data={"global": ipv4, "local": get_local_ip("ipv4")}, - status="SUCCESS" if ipv4 else "ERROR" if is_ipvx_important(4) else "WARNING", + status="SUCCESS" + if ipv4 + else "ERROR" + if is_ipvx_important(4) + else "WARNING", summary="diagnosis_ip_connected_ipv4" if ipv4 else "diagnosis_ip_no_ipv4", details=["diagnosis_ip_global", "diagnosis_ip_local"] if ipv4 else None, ) @@ -133,11 +137,19 @@ class MyDiagnoser(Diagnoser): yield dict( meta={"test": "ipv6"}, data={"global": ipv6, "local": get_local_ip("ipv6")}, - status="SUCCESS" if ipv6 else "ERROR" if is_ipvx_important(6) else "WARNING", + status="SUCCESS" + if ipv6 + else "ERROR" + if is_ipvx_important(6) + else "WARNING", summary="diagnosis_ip_connected_ipv6" if ipv6 else "diagnosis_ip_no_ipv6", details=["diagnosis_ip_global", "diagnosis_ip_local"] if ipv6 - else ["diagnosis_ip_no_ipv6_tip_important" if is_ipvx_important(6) else "diagnosis_ip_no_ipv6_tip"], + else [ + "diagnosis_ip_no_ipv6_tip_important" + if is_ipvx_important(6) + else "diagnosis_ip_no_ipv6_tip" + ], ) # TODO / FIXME : add some attempt to detect ISP (using whois ?) ? diff --git a/src/diagnosers/14-ports.py b/src/diagnosers/14-ports.py index 57fb7cd98..b3ea3d48d 100644 --- a/src/diagnosers/14-ports.py +++ b/src/diagnosers/14-ports.py @@ -47,7 +47,10 @@ class MyDiagnoser(Diagnoser): ipversions = [] ipv4 = Diagnoser.get_cached_report("ip", item={"test": "ipv4"}) or {} - if ipv4.get("status") == "SUCCESS" or settings_get("misc.network.dns_exposure") != "ipv6": + if ( + ipv4.get("status") == "SUCCESS" + or settings_get("misc.network.dns_exposure") != "ipv6" + ): ipversions.append(4) # To be discussed: we could also make this check dependent on the @@ -121,7 +124,10 @@ class MyDiagnoser(Diagnoser): for record in dnsrecords.get("items", []) ) - if (failed == 4 and settings_get("misc.network.dns_exposure") in ["both", "ipv4"]) or (failed == 6 and ipv6_is_important()): + if ( + failed == 4 + and settings_get("misc.network.dns_exposure") in ["both", "ipv4"] + ) or (failed == 6 and ipv6_is_important()): yield dict( meta={"port": port}, data={ diff --git a/src/diagnosers/21-web.py b/src/diagnosers/21-web.py index 25554fe9d..64775180c 100644 --- a/src/diagnosers/21-web.py +++ b/src/diagnosers/21-web.py @@ -77,7 +77,9 @@ class MyDiagnoser(Diagnoser): ipversions = [] ipv4 = Diagnoser.get_cached_report("ip", item={"test": "ipv4"}) or {} - if ipv4.get("status") == "SUCCESS" and settings_get("misc.network.dns_exposure") in ["both", "ipv4"]: + if ipv4.get("status") == "SUCCESS" and settings_get( + "misc.network.dns_exposure" + ) in ["both", "ipv4"]: ipversions.append(4) # To be discussed: we could also make this check dependent on the @@ -97,7 +99,10 @@ class MyDiagnoser(Diagnoser): # "curl --head the.global.ip" will simply timeout... if self.do_hairpinning_test: global_ipv4 = ipv4.get("data", {}).get("global", None) - if global_ipv4 and settings_get("misc.network.dns_exposure") in ["both", "ipv4"]: + if global_ipv4 and settings_get("misc.network.dns_exposure") in [ + "both", + "ipv4", + ]: try: requests.head("http://" + global_ipv4, timeout=5) except requests.exceptions.Timeout: @@ -148,7 +153,10 @@ class MyDiagnoser(Diagnoser): if all( results[ipversion][domain]["status"] == "ok" for ipversion in ipversions ): - if 4 in ipversions and settings_get("misc.network.dns_exposure") in ["both", "ipv4"]: + if 4 in ipversions and settings_get("misc.network.dns_exposure") in [ + "both", + "ipv4", + ]: self.do_hairpinning_test = True yield dict( meta={"domain": domain}, @@ -186,7 +194,9 @@ class MyDiagnoser(Diagnoser): ) AAAA_status = dnsrecords.get("data", {}).get("AAAA:@") - return AAAA_status in ["OK", "WRONG"] or settings_get("misc.network.dns_exposure") in ["both", "ipv6"] + return AAAA_status in ["OK", "WRONG"] or settings_get( + "misc.network.dns_exposure" + ) in ["both", "ipv6"] if failed == 4 or ipv6_is_important_for_this_domain(): yield dict( diff --git a/src/diagnosers/24-mail.py b/src/diagnosers/24-mail.py index 1ae1da885..785f33703 100644 --- a/src/diagnosers/24-mail.py +++ b/src/diagnosers/24-mail.py @@ -302,13 +302,17 @@ class MyDiagnoser(Diagnoser): outgoing_ipversions = [] outgoing_ips = [] ipv4 = Diagnoser.get_cached_report("ip", {"test": "ipv4"}) or {} - if ipv4.get("status") == "SUCCESS" and settings_get("misc.network.dns_exposure") in ["both", "ipv4"]: + if ipv4.get("status") == "SUCCESS" and settings_get( + "misc.network.dns_exposure" + ) in ["both", "ipv4"]: outgoing_ipversions.append(4) global_ipv4 = ipv4.get("data", {}).get("global", {}) if global_ipv4: outgoing_ips.append(global_ipv4) - if settings_get("email.smtp.smtp_allow_ipv6") or settings_get("misc.network.dns_exposure") in ["both", "ipv6"]: + if settings_get("email.smtp.smtp_allow_ipv6") or settings_get( + "misc.network.dns_exposure" + ) in ["both", "ipv6"]: ipv6 = Diagnoser.get_cached_report("ip", {"test": "ipv6"}) or {} if ipv6.get("status") == "SUCCESS": outgoing_ipversions.append(6)