def main():
    """Looping main function"""
    global pushcount
    pushcount = 1
    count = 1
    state = 'OK'
    sleeptime = checkperiod
    while 1:
        dprint('Probing Alerta URI: %s' % (alertaURL))
        response = Event()
        dprint('Probe Response: [ Code: %s | Body: %s | Epoch: %d ]' % \
        (response.code, response.body, response.epoch))
        dprint('\nCOUNT: %d' % (count))
        if response.code != 200:
            dprint('Event Triggered')
            if count == 1:
                cache = response
                dprint('Caching first event: [ Code: %d | Body: %s | Epoch: %d ]' % \
                    (cache.code, cache.body, cache.epoch))
            if count == tko:
                #Warnings
                if response.body ==\
                 'HEARTBEAT_STALE':
                    state = 'WARNING'
                    dprint('State: \033[93mWARNING\033[0m')
                    mailalert(response, cache, state)
                    pushover(response, state)
                    pushcount += 1
                    count = 0 # Reset for tko more tries.
                    sleeptime = checkperiod
                    dprint('\nRe-Probing in %d seconds...' % (sleeptime))
                    time.sleep(sleeptime)
                    continue
                else:
                #Criticals
                    state = 'CRITICAL'
                    dprint('State: \033[91mCRITICAL\033[0m')
                    mailalert(response, cache, state)
                    pushover(response, state)
                    pushcount += 1
                    count = 0 # Reset for tko more tries.
                    sleeptime = checkperiod
                    dprint((sleeptime) % '\nRe-Probing in %d seconds...')
                    time.sleep(sleeptime)
                    continue
            count += 1
            sleeptime = retrytime
        elif response.code == 200:
            dprint('State: \033[92mOK\033[0m')
            if state != 'OK':
                state = 'OK'
                pushcount = 0
                mailalert(response, cache, state)
                pushover(response, state)
            sleeptime = checkperiod
            count = 1
        dprint('\nRe-Probing in %d seconds...' % (sleeptime))
        time.sleep(sleeptime)
dataset/ETHPy150Open guardian/alerta/contrib/watchdog.py/main/swapped operands of `%`