Beispiel #1
0
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)
Beispiel #2
0
def timer(bot):
    last_date = None
    last_dsa_check = None

    while not (hasattr(bot, 'connection') and bot.connection.connected):
        time.sleep(2)

    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 in timer: {format_exc()}'
            bot.say('#rebuild', error_msg)
            bot.handle_error(
                dedent(
                    """
                {error}

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

        time.sleep(1)
Beispiel #3
0
def timer(bot):
    dsa_freq = DSA_FREQ_DEFAULT

    last_date = None
    last_dsa_check = None

    while not (hasattr(bot, 'connection') and bot.connection.connected):
        time.sleep(2)

    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)

                # After a successful fetch, we reset timer to 5m
                dsa_freq = DSA_FREQ_DEFAULT
        except Exception as ex:
            error_msg = f'ircbot exception in timer: {ex}'
            bot.say('#rebuild', error_msg)
            bot.handle_error(
                dedent(
                    """
                {error}

                {traceback}
                """
                ).format(
                    error=error_msg,
                    traceback=format_exc(),
                ),
            )
            dsa_freq = min(dsa_freq + DSA_FREQ_BACKOFF, DSA_FREQ_MAX)

        time.sleep(1)
Beispiel #4
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)
Beispiel #5
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:
        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)