Chromium Code Reviews| Index: scripts/slave/recipe_modules/perf_try/build_state.py |
| diff --git a/scripts/slave/recipe_modules/perf_try/build_state.py b/scripts/slave/recipe_modules/perf_try/build_state.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..808a7ccbdecfc5151569b129bd086d4aa08b3719 |
| --- /dev/null |
| +++ b/scripts/slave/recipe_modules/perf_try/build_state.py |
| @@ -0,0 +1,49 @@ |
| +""" |
|
RobertoCN
2016/06/24 18:46:37
Nit: add copy right header.
Ziqi Xiong
2016/06/27 18:47:54
Done.
|
| + Most code in this class are copied or adapted from revision_state in |
|
RobertoCN
2016/06/24 18:46:37
This docstring looks more like a comment.
Replace
Ziqi Xiong
2016/06/27 18:47:54
Done.
|
| + auto_bisect module. Future refactoring is needed. |
| +""" |
| + |
| +import json |
| +import uuid |
| + |
| +class BuildState(object): |
| + |
| + SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION = range(5) |
| + |
| + def __init__(self, api, commit_hash, with_patch): |
| + super(BuildState, self).__init__() |
| + self.api = api |
| + self.commit_hash = str(commit_hash) |
| + self._patch_hash = with_patch * str(uuid.uuid4()) |
| + self.build_id = None |
| + if with_patch: |
| + self.bucket = 'chrome-perf-tryjob' |
| + else: |
| + self.bucket = 'chrome-perf' |
| + self.build_file_path = self._get_build_file_path() |
| + |
| + def _get_build_file_path(self): |
| + revision_suffix = '%s.zip' % (self.commit_hash + self._patch_hash) |
| + return self._get_platform_gs_prefix() + revision_suffix |
| + |
| + def _get_platform_gs_prefix(self): |
| + bot_name = self.api.m.properties.get('buildername', '') |
| + if 'win' in bot_name: |
| + if any(b in bot_name for b in ['x64', 'gpu']): |
| + return 'gs://%s/Win x64 Builder/full-build-win32_' % self.bucket |
| + return 'gs://%s/Win Builder/full-build-win32_' % self.bucket |
| + if 'android' in bot_name: |
| + if 'nexus9' in bot_name: |
| + return 'gs://%s/android_perf_rel_arm64/full-build-linux_' % self.bucket |
| + return 'gs://%s/android_perf_rel/full-build-linux_' % self.bucket |
| + if 'mac' in bot_name: |
| + return 'gs://%s/Mac Builder/full-build-mac_' % self.bucket |
| + return 'gs://%s/Linux Builder/full-build-linux' % self.bucket |
| + |
| + def is_completed(self): |
| + result = self.api.m.buildbucket.get_build(self.build_id) |
| + return result.stdout['status'] == 'COMPLETED' |
| + |
| + def is_build_archived(self): |
| + result = self.api.m.buildbucket.get_build(self.build_id) |
| + return result.stdout['result'] == 'SUCCESS' |