From 49fafab88f6023270bb3bed9328d9ac542065506 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Thu, 14 Jun 2018 21:58:15 +0200 Subject: [PATCH] Added option for send mail if programming error --- paramecio/citoplasma/error_reporting.py | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 paramecio/citoplasma/error_reporting.py diff --git a/paramecio/citoplasma/error_reporting.py b/paramecio/citoplasma/error_reporting.py new file mode 100644 index 0000000..cd0dfae --- /dev/null +++ b/paramecio/citoplasma/error_reporting.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +# A bottle plugin for send emails if + +from settings import config +from paramecio.citoplasma.sendmail import SendMail + +class ErrorReportingPlugin(object): + + name = 'login' + api = 2 + + def apply(self, callback, context): + + def wrapper(*args, **kwargs): + + try: + + rv = callback(*args, **kwargs) + + return rv + + except: + + #print('detected error') + + # Send mail with error. + """ + sendmail=SendMail() + + sendmail.send(email_failed, [email_failed], 'Hubo un error al aƱadir el mail a mailchimp', r.text, content_type='plain', attachments=[]) + print(post.post['email']+'error in mailchimp: '+r.text) + + rv = callback(*args, **kwargs) + """ + raise + #return rv + + return wrapper