Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Script to download sdk/extras packages on the bots from google storage.""" | |
| 7 | |
| 8 import os | |
| 9 import subprocess | |
| 10 import sys | |
| 11 | |
| 12 sys.path.insert(0, os.path.join('android')) | |
| 13 from pylib import constants | |
| 14 | |
| 15 GSUTIL_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, | |
| 16 os.pardir, os.pardir, os.pardir, 'third_party', 'gsutil', 'gsutil') | |
| 17 SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras' | |
| 18 SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras') | |
| 19 GSUTIL_PATH = '/usr/local/google/code/gsutil/gsutil' | |
|
navabi
2014/11/07 04:16:02
oops. i put this in to test locally.
| |
| 20 | |
| 21 | |
| 22 def GetCmdOutputAndStatus(cmd_lst): | |
| 23 process = subprocess.Popen(cmd_lst, stdout=subprocess.PIPE) | |
| 24 stdout, _ = process.communicate() | |
| 25 return stdout, process.returncode | |
| 26 | |
| 27 def is_buildbot_checkout(): | |
| 28 if not os.path.exists(GSUTIL_PATH): | |
| 29 return False | |
| 30 stdout, rc = GetCmdOutputAndStatus([GSUTIL_PATH, 'ls', SDK_EXTRAS_BUCKET]) | |
| 31 # If successfully read bucket, then this must be a bot with permissions | |
| 32 return not rc | |
| 33 | |
| 34 def main(): | |
| 35 if is_buildbot_checkout(): | |
| 36 cmd_lst = [GSUTIL_PATH, 'cp', '-r', SDK_EXTRAS_BUCKET, SDK_EXTRAS_PATH] | |
| 37 stdout, rc = GetCmdOutputAndStatus(cmd_lst) | |
| 38 return rc | |
| 39 return 0 | |
| 40 | |
| 41 | |
| 42 if __name__ == '__main__': | |
| 43 sys.exit(main()) | |
| OLD | NEW |