From a9471920c5b5305e21f85ded424875ec7f93f73a Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 10 May 2012 11:40:06 +0000 Subject: [PATCH] add an --ip option to the sendmail command, pass the logger to send_mail_notifications, add a --file option to send from a file --- docbow_project/docbow/management/commands/sendmail.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docbow_project/docbow/management/commands/sendmail.py b/docbow_project/docbow/management/commands/sendmail.py index 59f9812..0e99396 100644 --- a/docbow_project/docbow/management/commands/sendmail.py +++ b/docbow_project/docbow/management/commands/sendmail.py @@ -34,7 +34,8 @@ In case of failure the following return value is returned: option_list = BaseCommand.option_list + ( make_option("--sender"), make_option("--base-url", default="http://localhost:8000"), - make_option("--ip", default='')) + make_option("--ip", default=''), + make_option("--file")) def handle(self, *args, **options): mail_sender = None @@ -47,7 +48,10 @@ In case of failure the following return value is returned: raise CommandError('Not found') try: - mail = email.message_from_file(sys.stdin) + if 'file' in options: + mail = email.message_from_file(file(options['file'])) + else: + mail = email.message_from_file(sys.stdin) except email.errors.MessageParseError, e: self.error('7.7.1 Error parsing message', exite_code=1) try: @@ -154,7 +158,7 @@ In case of failure the following return value is returned: attached_file.content.save(filename, content, save=False) attached_file.save() document.post() - if not views.send_mail_notifications(document, options['base_url']): + if not views.send_mail_notifications(document, options['base_url'], logger=self.logger): transaction.rollback() self.error('7.7.1 Document send failed because ' 'some notifications could not be sent, administrators '