skia2/infra/bots/recipe_modules/swarming/state.py
Eric Boren f94514b0ff [recipes] Copy file, isolate, swarming, swarming_client from build.git
Rename swarming -> skia_swarming.
Some required heavy modification to remove other dependencies on modules
in build.git.

Expected changes:

- RECIPE_MODULE[build::<module>] -> RECIPE_MODULE[skia::<module>]
- No more runit; directly run through Python.

Bug: skia:6628
Change-Id: I1b1370ed387966222ce10731771dbde9020cf542
Reviewed-on: https://skia-review.googlesource.com/17448
Commit-Queue: Eric Boren <borenet@google.com>
Reviewed-by: Ravi Mistry <rmistry@google.com>
2017-05-22 13:08:25 +00:00

47 lines
1.3 KiB
Python

# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# TODO(borenet): This module was copied from build.git and heavily modified to
# remove dependencies on other modules in build.git. It belongs in a different
# repo. Remove this once it has been moved.
class State(object):
"""Copied from appengine/swarming/server/task_result.py.
KEEP IN SYNC.
Used to parse the 'state' value in task result.
"""
RUNNING = 0x10 # 16
PENDING = 0x20 # 32
EXPIRED = 0x30 # 48
TIMED_OUT = 0x40 # 64
BOT_DIED = 0x50 # 80
CANCELED = 0x60 # 96
COMPLETED = 0x70 # 112
STATES = (
RUNNING, PENDING, EXPIRED, TIMED_OUT, BOT_DIED, CANCELED, COMPLETED)
STATES_RUNNING = (RUNNING, PENDING)
STATES_NOT_RUNNING = (EXPIRED, TIMED_OUT, BOT_DIED, CANCELED, COMPLETED)
STATES_DONE = (TIMED_OUT, COMPLETED)
STATES_ABANDONED = (EXPIRED, BOT_DIED, CANCELED)
_NAMES = {
RUNNING: 'Running',
PENDING: 'Pending',
EXPIRED: 'Expired',
TIMED_OUT: 'Execution timed out',
BOT_DIED: 'Bot died',
CANCELED: 'User canceled',
COMPLETED: 'Completed',
}
@classmethod
def to_string(cls, state):
"""Returns a user-readable string representing a State."""
return cls._NAMES[state]