aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/gsutil/api.py
diff options
context:
space:
mode:
authorGravatar Kevin Lubick <kjlubick@google.com>2017-10-09 15:26:19 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-09 19:58:34 +0000
commitc795a4c8862dbab914561fadf7a3567c55362ae4 (patch)
tree725e0fc4209029005230fdd4db48035d3aebd52a /infra/bots/recipe_modules/gsutil/api.py
parentdf007e1a7ae808ad41eb2bd01f6a658c5b438285 (diff)
Add Linux CPU Coverage Bot
This simply uploads the results of an LLVM coverage to GCS for later ingestion/display. Bug: skia:7080 Change-Id: I7dcfa2307a239734a614990aca899ea37129126b Reviewed-on: https://skia-review.googlesource.com/53880 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Eric Boren <borenet@google.com>
Diffstat (limited to 'infra/bots/recipe_modules/gsutil/api.py')
-rw-r--r--infra/bots/recipe_modules/gsutil/api.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/infra/bots/recipe_modules/gsutil/api.py b/infra/bots/recipe_modules/gsutil/api.py
new file mode 100644
index 0000000000..babf85270b
--- /dev/null
+++ b/infra/bots/recipe_modules/gsutil/api.py
@@ -0,0 +1,38 @@
+# 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.
+
+
+from recipe_engine import recipe_api
+
+UPLOAD_ATTEMPTS = 5
+
+class GSUtilApi(recipe_api.RecipeApi):
+ def cp(self, name, src, dst, extra_args=None):
+ """Attempt to upload or download files to/from Google Cloud Storage (GCS).
+
+ Args:
+ name: string. Will be used to fill out the step name.
+ src: string. Absolute path for a local file or gcs file (e.g. gs://...)
+ dst: string. Same as src.
+ extra_args: optional list of args to be passed to gsutil. e.g. [-Z] asks
+ all files be compressed with gzip after upload and before download.
+
+ If the operation fails, it will be retried multiple times.
+ """
+ cmd = ['gsutil', 'cp']
+ if extra_args:
+ cmd.extend(extra_args)
+ cmd.extend([src, dst])
+
+ name = 'upload %s' % name
+ for i in xrange(UPLOAD_ATTEMPTS):
+ step_name = name
+ if i > 0:
+ step_name += ' (attempt %d)' % (i+1)
+ try:
+ self.m.step(step_name, cmd=cmd)
+ break
+ except self.m.step.StepFailure:
+ if i == UPLOAD_ATTEMPTS - 1:
+ raise