def mailalert(last, cache, typestr):
    if 3 > pushcount:
        dprint('Info: Not sending Email notification - too many messages for event')
        return
    elif pushcount == 3:
        suppnote = 'Further notifications will be suppressed.'
    else:
        suppnote = ' '
    msg = MIMEMultipart('alternative')
    msg['Subject'] = "Alerta Service Notification"
    msg['From'] = fromaddr
    msg['To'] = ', '.join(toaddr)
    if typestr == 'WARNING':
        colour = 'ff8c00'
    elif typestr == 'CRITICAL':
        colour = 'ff0000'
    elif typestr == 'OK':
        colour = '00ff00'
    text = """\
    Alerta state change: %s - Response: %s (Code: %d)

    TKO: %d
    Soft Event logged at %s
    Hard Event logged at %s

    Service Probed: %s

    %s

    Auto-generated by Alerta-WatchDog

    --

    """ % (typestr, last.body, last.code, tko, cache.human, \
        last.human, alertaURL, suppnote)
    html = """\
    <html>
    <head></head>
    <body>
     <p>
     Alerta state change: <span style="background-color:#%s;">%s</span> - Response: <b>%s</b> (Code: %d)<br />
     <br />
     <I>TKO</I>: %d<br />
     &nbsp;&nbsp; &nbsp;<I>Soft Event triggered at</I> %s<br />
     &nbsp;&nbsp; &nbsp;<I>Hard Event triggered at</I> %s<br />
     <br />
     &nbsp;&nbsp; &nbsp;<I>Service Probed:</I> %s</p>
     <p><I><B>%s</I></B></p>
     <p><I>Auto-generated by Alerta-WatchDog</I><p>
     --
    </body>
    </html>
    """ % (colour, typestr, last.body, last.code, tko, cache.human, \
        last.human, alertaURL, suppnote)

    textpart = MIMEText(text, 'plain')
    htmlpart = MIMEText(html, 'html')
    msg.attach(textpart)
    msg.attach(htmlpart)

    s=smtplib.SMTP(smtphost)
    s.sendmail(fromaddr, toaddr, msg.as_string())

    dprint('\033[92mMAIL SENT\033[0m\n' + text)
dataset/ETHPy150Open guardian/alerta/contrib/watchdog.py/mailalert/swapped operands of `>`