From 59d3992284331ed72fb4df015dcb466004cb3a4f Mon Sep 17 00:00:00 2001 From: Christoph Goehre Date: Mon, 17 Nov 2008 17:39:52 +0100 Subject: check mail_template strings for existence If You create changes files with 'changestool' from the debian package reprepro, it result in changes files without 'Changes' and 'Changed-By' fields. So mini-dinstall will crash if sending succes upload emails. But in the other hand, its better to check 'by user' configurable vars anyway. --- mini-dinstall | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/mini-dinstall b/mini-dinstall index fa21961..91fb4e9 100755 --- a/mini-dinstall +++ b/mini-dinstall @@ -796,9 +796,24 @@ class ArchiveDir: do_rename(changefilename, target) self._logger.info('Successfully installed %s %s to %s' % (sourcename, version, self._name)) if self._mail_on_success: - changefile ['changes_without_dot'] = misc.format_changes(changefile['changes']) - self.mailHandler.setSubject(mail_subject_template % changefile) - self._success_logger.info(mail_body_template % changefile) + done = False + missing_fields = [] + if changefile.has_key('changes'): + changefile ['changes_without_dot'] = misc.format_changes(changefile['changes']) + while not done: + try: + mail_subject = mail_subject_template % changefile + mail_body = mail_body_template % changefile + except KeyError, exc: + key = exc.args[0] + changefile[key] = '' + missing_fields.append(key) + else: + done = True + if missing_fields: + mail_body = mail_body + "\n\nMissing changefile fields: %s" % missing_fields + self.mailHandler.setSubject(mail_subject) + self._success_logger.info(mail_body) if self._post_install_script: try: -- cgit v1.2.3