From b332845431bd5bab48e31949e02b608dd6fb4e92 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Fri, 26 Jul 2013 12:05:28 +0200 Subject: [PATCH] [bcfg2_report] On n'envoie pas de mail si tout est clean. --- bcfg2/bcfg2_report.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bcfg2/bcfg2_report.py b/bcfg2/bcfg2_report.py index 0d97c083..3cdc4c3a 100755 --- a/bcfg2/bcfg2_report.py +++ b/bcfg2/bcfg2_report.py @@ -42,8 +42,11 @@ if __name__ == "__main__": exit(1) debug = "--debug" in sys.argv if "--mail" in sys.argv: - sys.path.append("/usr/scripts/") - import utils.sendmail - utils.sendmail.sendmail("root@crans.org", "roots@crans.org", u"Serveurs non synchronisés avec bcfg2", hosts, more_headers={"X-Mailer" : "bcfg2-reports"}, debug=debug) + if hosts != "": + sys.path.append("/usr/scripts/") + import utils.sendmail + utils.sendmail.sendmail("root@crans.org", "roots@crans.org", u"Serveurs non synchronisés avec bcfg2", hosts, more_headers={"X-Mailer" : "bcfg2-reports"}, debug=debug) + elif debug: + print("Empty content, no mail sent") else: - print(hosts) + print(hosts, end="") -- GitLab