OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 |
| 6 from recipe_engine import recipe_api |
| 7 |
| 8 import re |
| 9 |
| 10 |
| 11 class CTApi(recipe_api.RecipeApi): |
| 12 """Provides steps to run CT tasks.""" |
| 13 |
| 14 CT_GS_BUCKET = 'cluster-telemetry' |
| 15 |
| 16 def download_swarming_skps(self, page_type, slave_num, skps_chromium_build, |
| 17 dest_dir, start_range, num_skps): |
| 18 """Downloads SKPs corresponding to the specified page type, slave and build. |
| 19 |
| 20 The SKPs are stored in Google Storage in the following dirs in CT_GS_BUCKET: |
| 21 /swarming/skps/${page_type}/${skps_chromium_build}/{start_range..end_num}/ |
| 22 The SKPs are downloaded into subdirectories in the dest_dir. |
| 23 |
| 24 Args: |
| 25 api: RecipeApi instance. |
| 26 page_type: str. The CT page type. Eg: 1k, 10k. |
| 27 slave_num: int. The number of the swarming bot. |
| 28 skps_chromium_build: str. The build the SKPs were captured from. |
| 29 dest_dir: path obj. The directory to download SKPs into. |
| 30 start_range: int. The subdirectory number to start from. |
| 31 num_skps: int. The total number of SKPs to download starting with |
| 32 start_range. |
| 33 """ |
| 34 slave_dest_dir = dest_dir.join('slave%s' % slave_num ) |
| 35 remote_dir = 'gs://%s/swarming/skps/%s/%s' % ( |
| 36 self.CT_GS_BUCKET, page_type, skps_chromium_build) |
| 37 |
| 38 # Delete and recreate the local dir. |
| 39 self.m.run.rmtree(slave_dest_dir) |
| 40 self.m.file.makedirs(self.m.path.basename(slave_dest_dir), slave_dest_dir) |
| 41 |
| 42 # Populate the empty local dir. |
| 43 gsutil_args = ['-m', 'cp'] |
| 44 for i in range(start_range, start_range+num_skps): |
| 45 gsutil_args.append('%s/%s/*.skp' % (str(remote_dir), i)) |
| 46 gsutil_args.append(str(slave_dest_dir)) |
| 47 try: |
| 48 self.m.gsutil(gsutil_args, use_retry_wrapper=False) |
| 49 except self.m.step.StepFailure: # pragma: nocover |
| 50 # Some subdirectories might have no SKPs in them. |
| 51 pass |
OLD | NEW |