def started(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In started event.", attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id

        # An existing wait_duration implies the patch had been started previously and is
        # being picked up again because it had expired, or was released.
        if patch_log.wait_duration is not None:
            patch_log.retry_count += 1
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_retry_count += 1
            queue_log.put()
        else:
            patch_log.calculate_wait_duration()
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_wait_durations.append(patch_log.wait_duration)
            queue_log.put()
Example #2
0
    def stopped(cls, attachment_id, queue_name, status_message, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In stopped event.",
                              attachment_id, queue_name, bot_id)
            return

        if patch_log.wait_duration is None:
            WarningLog.record("patchlog wait duration missing",
                              "In stopped event.", attachment_id, queue_name,
                              bot_id)
            return

        if not patch_log.finished:
            if bot_id:
                patch_log.bot_id = bot_id
            patch_log.finished = True
            patch_log.calculate_process_duration()
            patch_log.latest_message = status_message
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_process_durations.append(
                patch_log.process_duration)
            queue_log.put()
Example #3
0
    def started(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In started event.",
                              attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id

        # An existing wait_duration implies the patch had been started previously and is
        # being picked up again because it had expired, or was released.
        if patch_log.wait_duration is not None:
            patch_log.retry_count += 1
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_retry_count += 1
            queue_log.put()
        else:
            patch_log.calculate_wait_duration()
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_wait_durations.append(patch_log.wait_duration)
            queue_log.put()
    def updated(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In updated event.", attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.status_update_count += 1
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.status_update_count += 1
        queue_log.put()
Example #5
0
    def updated(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In updated event.", attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.status_update_count += 1
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.status_update_count += 1
        queue_log.put()
    def stopped(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In stopped event.", attachment_id, queue_name, bot_id)
            return

        if not patch_log.wait_duration:
            WarningLog.record("patchlog wait duration missing", "In stopped event.", attachment_id, queue_name, bot_id)
            return

        if not patch_log.finished:
            if bot_id:
                patch_log.bot_id = bot_id
            patch_log.finished = True
            patch_log.calculate_process_duration()
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_process_durations.append(patch_log.process_duration)
            queue_log.put()