예제 #1
0
파일: ircbot.py 프로젝트: dkess/ircbot
def timer(bot):
    last_date = None
    last_dsa_check = None
    last_monitor_check = None
    last_monitor_status = None

    while not bot.connection.connected:
        time.sleep(2)

    # TODO: timers should register as plugins like listeners do
    while True:
        last_date, old = date.today(), last_date
        if old and last_date != old:
            bot.bump_topic()

        if last_dsa_check is None or time.time() - last_dsa_check > 60 * DSA_FREQ:
            last_dsa_check = time.time()

            for line in debian_security.get_new_dsas():
                bot.say('#rebuild', line)

        if last_monitor_check is None or time.time() - last_monitor_check > 60 * MONITOR_FREQ:
            last_monitor_check = time.time()
            new_monitor_status = rackspace_monitoring.get_summary(bot.rackspace_apikey)

            # Only print out Rackspace status if it has changed since the last check
            if last_monitor_status and last_monitor_status != new_monitor_status:
                bot.say('#rebuild', new_monitor_status)

            last_monitor_status = new_monitor_status

        time.sleep(1)
예제 #2
0
def timer(bot):
    last_date = None
    last_dsa_check = None

    while not bot.connection.connected:
        time.sleep(2)

    # TODO: timers should register as plugins like listeners do
    while True:
        last_date, old = date.today(), last_date
        if old and last_date != old:
            bot.bump_topic()

        if last_dsa_check is None or time.time(
        ) - last_dsa_check > 60 * DSA_FREQ:
            last_dsa_check = time.time()

            for line in debian_security.get_new_dsas():
                bot.say('#rebuild', line)

        time.sleep(1)
예제 #3
0
파일: ircbot.py 프로젝트: jameslzhu/ircbot
def timer(bot):
    last_date = None
    last_dsa_check = None

    while not bot.connection.connected:
        time.sleep(2)

    # TODO: timers should register as plugins like listeners do
    while True:
        try:
            last_date, old = date.today(), last_date
            if old and last_date != old:
                bot.bump_topic()

            if last_dsa_check is None or time.time(
            ) - last_dsa_check > 60 * DSA_FREQ:
                last_dsa_check = time.time()

                for line in debian_security.get_new_dsas():
                    bot.say('#rebuild', line)
        except Exception:
            error_msg = f'ircbot exception: {format_exc()}'
            bot.say('#rebuild', error_msg)
            # don't send emails when running as dev
            if not TESTING:
                send_problem_report(
                    dedent("""
                    {error}

                    {traceback}
                    """).format(
                        error=error_msg,
                        traceback=format_exc(),
                    ), )

        time.sleep(1)