def do_notify(self, settings, notification_struct): af = settings['admin_fields'] rf = settings['receiver_fields'] title = self._create_title(notification_struct) body = self._create_email(notification_struct, af['username'], rf['mail_addr'], title) try: smtpsock = self._get_SMTP(af['server'], af['port'], af['ssl'], af['username'], af['password']) if not smtpsock: log.err("[E] error in sending the email to %s (username: %s)" % (rf['mail_addr'], af['username'])) return False smtpsock.sendmail(af['username'], [ rf['mail_addr'] ], body) smtpsock.quit() log.debug("Success in email %s " % rf['mail_addr']) return True except smtplib.SMTPRecipientsRefused, smtplib.SMTPSenderRefused: # remind, other error can be handled http://docs.python.org/2/library/smtplib.html log.err("[E] error in sending the email to %s (username: %s)" % (rf['mail_addr'], af['username'])) return False
def createTables(): """ @return: None, create the right table at the first start, and initialized the node """ from globaleaks import models from globaleaks.db import tables for m in [models.node, models.context, models.receiver, models.submission, models.externaltip, models.internaltip, models.admin ]: for model_name in m.__all__: try: model = getattr(m, model_name) except Exception, e: log.err("Error in db initting") log.err(e) try: log.debug("Creating %s" % model) yield tables.runCreateTable(model, transactor, database) except Exception, e: log.debug(str(e))