Index: build/download_sdk_extras.py |
diff --git a/build/download_sdk_extras.py b/build/download_sdk_extras.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..1f22d7b4d938d469c5bf361a1b68d127aeac5c3e |
--- /dev/null |
+++ b/build/download_sdk_extras.py |
@@ -0,0 +1,48 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2014 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. |
+ |
+"""Script to download sdk/extras packages on the bots from google storage.""" |
+ |
+import os |
+import subprocess |
+import sys |
+ |
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'android')) |
+from pylib import constants |
+ |
+GSUTIL_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, |
+ os.pardir, os.pardir, os.pardir, 'third_party', 'gsutil', 'gsutil') |
+SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras' |
nyquist
2014/11/25 20:08:26
Does this already have the exact same content (exc
navabi
2014/11/25 20:40:49
Yes.
|
+SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras') |
nyquist
2014/11/25 20:08:26
It feels like there should be a .gitignore in http
navabi
2014/11/25 20:40:49
Yes. It is in place, in that the head of the andro
nyquist
2014/11/26 03:17:29
So you also cleaned out that folder? Or are you sa
|
+ |
+ |
+def GetCmdOutputAndStatus(cmd_lst): |
+ process = subprocess.Popen(cmd_lst, stdout=subprocess.PIPE) |
+ stdout, _ = process.communicate() |
+ return stdout, process.returncode |
+ |
+def is_buildbot_checkout(): |
nyquist
2014/11/25 20:08:26
this is a little bit odd to me, but I don't have a
navabi
2014/11/25 20:40:49
I'll consider it. But even if we checked some othe
|
+ if not os.path.exists(GSUTIL_PATH) or not os.path.exists(SDK_EXTRAS_PATH): |
+ return False |
+ stdout, rc = GetCmdOutputAndStatus([GSUTIL_PATH, 'ls', SDK_EXTRAS_BUCKET]) |
+ # If successfully read bucket, then this must be a bot with permissions |
+ return not rc |
+ |
+def main(args): |
+ if is_buildbot_checkout(): |
+ success = True |
+ for arg in args[1:]: |
+ package_bucket = '%s/%s' % (SDK_EXTRAS_BUCKET, arg) |
+ cmd_lst = [GSUTIL_PATH, '-m', 'rsync', '-r', package_bucket, |
nyquist
2014/11/25 20:08:26
would you want '-d' here to delete the files that
navabi
2014/11/25 20:40:49
No. That would remove other packages the way we cu
|
+ SDK_EXTRAS_PATH] |
+ stdout, rc = GetCmdOutputAndStatus(cmd_lst) |
+ success = (rc == 0) and success |
+ if not success: |
+ return 1 |
+ return 0 |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main(sys.argv)) |