Yield one item per port open to be consistent with other diagnosers

This commit is contained in:
Alexandre Aubin 2019-07-31 17:36:51 +02:00
parent 91ec775ebb
commit 612a96e1e2
3 changed files with 7 additions and 8 deletions

View file

@ -37,18 +37,15 @@ class PortsDiagnoser(Diagnoser):
except Exception as e: except Exception as e:
raise YunohostError("diagnosis_ports_could_not_diagnose", error=e) raise YunohostError("diagnosis_ports_could_not_diagnose", error=e)
found_issues = False
for port in ports: for port in ports:
if r["ports"].get(str(port), None) is not True: if r["ports"].get(str(port), None) is not True:
found_issues = True
yield dict(meta={"port": port}, yield dict(meta={"port": port},
status="ERROR", status="ERROR",
summary=("diagnosis_ports_unreachable", {"port": port})) summary=("diagnosis_ports_unreachable", {"port": port}))
else:
if not found_issues:
yield dict(meta={}, yield dict(meta={},
status="SUCCESS", status="SUCCESS",
summary=("diagnosis_ports_ok", {})) summary=("diagnosis_ports_ok", {"port": port}))
def main(args, env, loggers): def main(args, env, loggers):

View file

@ -181,7 +181,7 @@
"diagnosis_description_http": "HTTP exposure", "diagnosis_description_http": "HTTP exposure",
"diagnosis_ports_could_not_diagnose": "Could not diagnose if ports are reachable from outside. Error: {error}", "diagnosis_ports_could_not_diagnose": "Could not diagnose if ports are reachable from outside. Error: {error}",
"diagnosis_ports_unreachable": "Port {port} is not reachable from outside.", "diagnosis_ports_unreachable": "Port {port} is not reachable from outside.",
"diagnosis_ports_ok": "Relevant ports are reachable from outside!", "diagnosis_ports_ok": "Port {port} is reachable from outside.",
"diagnosis_http_could_not_diagnose": "Could not diagnose if domain is reachable from outside. Error: {error}", "diagnosis_http_could_not_diagnose": "Could not diagnose if domain is reachable from outside. Error: {error}",
"diagnosis_http_ok": "Domain {domain} is reachable from outside.", "diagnosis_http_ok": "Domain {domain} is reachable from outside.",
"diagnosis_http_unreachable": "Domain {domain} is unreachable through HTTP from outside.", "diagnosis_http_unreachable": "Domain {domain} is unreachable through HTTP from outside.",

View file

@ -116,8 +116,10 @@ def diagnosis_run(categories=[], force=False):
if issues: if issues:
if msettings.get("interface") == "api": if msettings.get("interface") == "api":
# FIXME: i18n
logger.info("You can go to the Diagnosis section (in the home screen) to see the issues found.") logger.info("You can go to the Diagnosis section (in the home screen) to see the issues found.")
else: else:
# FIXME: i18n
logger.info("You can run 'yunohost diagnosis show --issues' to display the issues found.") logger.info("You can run 'yunohost diagnosis show --issues' to display the issues found.")
return return