Exemplo n.º 1
0
def apflog(msg, level='Notice', echo=True):
    """Wraps the APF.log function. Messages are logged as 'master'."""

    APF.log(str(msg), level=level, echo=echo)
    
    if level in ['error']:
        subject = "[APF] An Error has occured"
        sendmail(subject, msg, to=['*****@*****.**'])
    if level in ['Crit', 'Alert', 'Emerg']:
        subject = "[APF] An Error has occured"
        sendmail(subject, msg, to=['*****@*****.**','*****@*****.**'])
Exemplo n.º 2
0
def sendmail(subject, body, to=['*****@*****.**']):
    APF.log("Sending error message to" + str(to))

    me = "APF <*****@*****.**>"

    msg = MIMEMultipart()
    msg["Subject"] = subject
    msg["From"] = me
    msg["To"] = ', '.join(to)
    msg.attach(MIMEText(body + "\n"))
    user_msg = "Script was being run by user %s" % getpass.getuser()
    msg.attach(MIMEText(user_msg))

    s = smtplib.SMTP('localhost')
    s.sendmail(me, to, msg.as_string())
    s.quit()
Exemplo n.º 3
0
def apflog(msg, level='Notice', echo=True):
    """Wraps the APF.log function. Messages are logged as 'master'."""

    APF.log(str(msg), level=level, echo=echo)

    if level in ['error']:
        subject = "[APF] An Error has occured"
        sendmail(subject, msg, to=['*****@*****.**'])
    if level in ['Crit', 'Alert', 'Emerg']:
        subject = "[APF] An Error has occured"
        sendmail(subject,
                 msg,
                 to=[
                     '*****@*****.**', '[email protected] ',
                     '*****@*****.**'
                 ])
Exemplo n.º 4
0
def sendmail(subject, body, to=['*****@*****.**']):
    APF.log("Sending error message to" + str(to))
    
    me = "APF <*****@*****.**>"

    msg = MIMEMultipart()
    msg["Subject"] = subject
    msg["From"] = me
    msg["To"] = ', '.join(to)
    msg.attach(MIMEText(body))
    user_msg = "Script was being run by user %s" % getpass.getuser()
    msg.attach(MIMEText(user_msg))

    s = smtplib.SMTP('localhost')
    s.sendmail(me, to, msg.as_string())
    s.quit()