def retrieveProfileNotifications(self, profData): try: assert isinstance(profData, ImmutableDataWrapper) d = profData._getData() assert isinstance(d, dataprops.ProfileData) result = [] for req in d.notifyFailedRequests: if req: result.append(_createReqNotif(profData, False, req)) for req in d.notifyDoneRequests: if req: result.append(_createReqNotif(profData, True, req)) params = d.notifyParams for sql in d.notifyFailedSQL: if sql: result.append(_createSQLNotif(profData, False, params, sql)) for sql in d.notifyDoneSQL: if sql: result.append(_createSQLNotif(profData, True, params, sql)) recipientsLine = d.notifyFailedMailRecipients if recipientsLine: recipients = utils.splitMailRecipients(recipientsLine) notification = _createMailNotif(profData, False, recipients) result.append(notification) return defer.succeed(result) except Exception, e: msg = "Failed to retrieve profile notifications data" ex = datasource.RetrievalError(msg, cause=e) f = failure.Failure(ex) return defer.fail(f)
def _postNotification(smtpServer, smtpPort, requireTLS, sender, recipients, body): senderAddr = utils.splitMailAddress(sender)[1] recipientsAddr = [f[1] for f in utils.splitMailRecipients(recipients)] return Notifier._postMail(smtpServer, smtpPort, None, None, senderAddr, recipientsAddr, StringIO(body), requireTLS=requireTLS, timeout=adminconsts.GLOBAL_MAIL_NOTIFY_TIMEOUT, retries=adminconsts.GLOBAL_MAIL_NOTIFY_RETRIES)