mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Change logic of --email to avoid sending empty mail is some issues are found but ignored
This commit is contained in:
parent
e140546092
commit
4cd4938eb4
1 changed files with 9 additions and 9 deletions
|
@ -183,10 +183,9 @@ def diagnosis_run(categories=[], force=False, except_if_never_ran_yet=False, ema
|
||||||
if report != {}:
|
if report != {}:
|
||||||
issues.extend([item for item in report["items"] if item["status"] in ["WARNING", "ERROR"]])
|
issues.extend([item for item in report["items"] if item["status"] in ["WARNING", "ERROR"]])
|
||||||
|
|
||||||
if issues:
|
|
||||||
if email:
|
if email:
|
||||||
_email_diagnosis_issues()
|
_email_diagnosis_issues()
|
||||||
elif msettings.get("interface") == "cli":
|
if issues and msettings.get("interface") == "cli":
|
||||||
logger.warning(m18n.n("diagnosis_display_tip"))
|
logger.warning(m18n.n("diagnosis_display_tip"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,7 +564,11 @@ def _email_diagnosis_issues():
|
||||||
|
|
||||||
disclaimer = "The automatic diagnosis on your YunoHost server identified some issues on your server. You will find a description of the issues below. You can manage those issues in the 'Diagnosis' section in your webadmin."
|
disclaimer = "The automatic diagnosis on your YunoHost server identified some issues on your server. You will find a description of the issues below. You can manage those issues in the 'Diagnosis' section in your webadmin."
|
||||||
|
|
||||||
content = _dump_human_readable_reports(diagnosis_show(issues=True)["reports"])
|
issues = diagnosis_show(issues=True)["reports"]
|
||||||
|
if not issues:
|
||||||
|
return
|
||||||
|
|
||||||
|
content = _dump_human_readable_reports(issues)
|
||||||
|
|
||||||
message = """\
|
message = """\
|
||||||
From: %s
|
From: %s
|
||||||
|
@ -579,9 +582,6 @@ Subject: %s
|
||||||
%s
|
%s
|
||||||
""" % (from_, to_, subject_, disclaimer, content)
|
""" % (from_, to_, subject_, disclaimer, content)
|
||||||
|
|
||||||
print(message)
|
|
||||||
|
|
||||||
smtp = smtplib.SMTP("localhost")
|
smtp = smtplib.SMTP("localhost")
|
||||||
smtp.sendmail(from_, [to_], message)
|
smtp.sendmail(from_, [to_], message)
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue