From 6ef4f4bc8fdc02b06dbe3a34a2492ce0d6689c11 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 22 Aug 2019 19:18:21 +0000 Subject: [PATCH] Emit an error for a missing E-mail template Instead of silently doing nothing when asked to render a message for an event with no available template, return nonzero and provide an explanation. Change-Id: I8b86ad1d90f8e83f0d37cade73a94be041b07ae7 --- openstack_election/cmds/template_emails.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openstack_election/cmds/template_emails.py b/openstack_election/cmds/template_emails.py index 0aa990fb..dc43b00d 100644 --- a/openstack_election/cmds/template_emails.py +++ b/openstack_election/cmds/template_emails.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import argparse import jinja2 import os +import sys from openstack_election.cmds import render_statistics as stats from openstack_election import config @@ -82,6 +83,7 @@ def main(): template = env.get_template('%s.j2' % func_name) print(template.render(fmt_args)) except jinja2.exceptions.TemplateNotFound: - pass + print('\nNo %s.j2 template found.\n' % func_name, file=sys.stderr) + return 1 return 0