1# Copyright (C) 2017 The Android Open-Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""A helper class for working with stored ARC build manifest files"""
16
17import logging
18import os
19
20import lib.util as util
21
22
23class BuildArtifactFetcher(object):
24  """Common code for working with ARC/Android build artifacts"""
25
26  def __init__(self, arch, variant, build_id):
27    self._arch = arch
28    self._variant = variant
29    self._build_id = build_id
30
31  @property
32  def arch(self):
33    return self._arch
34
35  @property
36  def variant(self):
37    return self._variant
38
39  @property
40  def build_id(self):
41    return self._build_id
42
43  def fetch(self, remote_path, local_path):
44    logging.info('Fetching %s ...', os.path.basename(local_path))
45    util.makedirs(os.path.dirname(local_path))
46    util.check_call(
47        '/google/data/ro/projects/android/fetch_artifact',
48        '--bid', self._build_id,
49        '--target', 'cheets_%s-%s' % (self._arch, self._variant),
50        remote_path, local_path)
51