Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1618)

Unified Diff: tools/dartium/download_multivm.py

Issue 291153010: Add multivm archive download script for buildbot use. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve Windows paths Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dartium/download_multivm.py
diff --git a/tools/dartium/download_multivm.py b/tools/dartium/download_multivm.py
new file mode 100755
index 0000000000000000000000000000000000000000..0ccf864bd485a20316e6fd7a45b9d6e860da68eb
--- /dev/null
+++ b/tools/dartium/download_multivm.py
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
ricow1 2014/05/22 12:40:19 use dart copyright notice?
Bill Hesse 2014/05/22 12:59:37 Done.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Download archived multivm or dartium builds.
+
+ Usage: download_multivm.py revision build_directory target_directory
+"""
+
+import os
+import platform
+import shutil
+import subprocess
+import sys
+
+BUILDER_NAME = 'BUILDBOT_BUILDERNAME'
+
+if platform.system() == 'Windows':
+ GSUTIL = 'e:\\b\\build\\scripts\\slave\\gsutil.bat'
+else:
+ GSUTIL = '/b/build/scripts/slave/gsutil'
+
+GS_SITE = 'gs://'
+GS_BUCKET = 'dartium-archive'
+# We are in [checkout dir]/src/dart/tools/dartium in a dartium/multivm checkout
+SRC_DIR = os.path.dirname(
+ os.path.dirname(
+ os.path.dirname(
+ os.path.dirname(__file__))))
+
+def DownloadArchive(bucket, revision, build_dir, target_dir):
+ dartium_bucket = bucket.replace('multivm', 'multivm-dartium')
+ dartium_archive = dartium_bucket + '-' + revision + '.zip'
+
+ source = '/'.join([GS_SITE + GS_BUCKET, dartium_bucket, dartium_archive])
+ zip_file = '/'.join([build_dir, dartium_archive])
+
+ if not os.path.exists(GSUTIL):
+ print('download_multivm.py must be run in a dartium or multivm checkout'
+ ' on a buildbot slave. Could not find gsutil at %s' % GSUTIL)
+ cmd = [GSUTIL, 'cp', source, zip_file]
+ (status, output) = ExecuteCommand(cmd)
+ if status:
+ print output
+ return status
+ unzip_result_dir = zip_file.replace('.zip', '')
+ if os.path.exists(unzip_result_dir):
+ shutil.rmtree(unzip_result_dir)
+
+ if platform.system() == 'Windows':
+ executable = os.path.join(SRC_DIR, 'third_party', 'lzma_sdk',
+ 'Executable', '7za.exe')
+ cmd = [executable, 'x', '-aoa', '-o%s' % build_dir, zip_file]
+ else:
+ cmd = ['unzip', zip_file, '-d', build_dir]
+ (status, output) = ExecuteCommand(cmd)
+ if status:
+ print output
+ return status
+ os.remove(zip_file)
+ if os.path.exists(target_dir):
+ shutil.rmtree(target_dir)
+ shutil.move(zip_file.replace('.zip', ''), target_dir)
+ return 0
+
+
+def ExecuteCommand(cmd):
+ """Execute a command in a subprocess.
+ """
+ print 'Executing: ' + ' '.join(cmd)
ricow1 2014/05/22 12:40:19 I suggest that we just use subprocess.check_output
Bill Hesse 2014/05/22 12:59:37 Done.
+ try:
+ pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (output, error) = pipe.communicate()
+ if pipe.returncode != 0:
+ print 'Execution failed: ' + str(error)
+ return (pipe.returncode, output)
+ except:
+ import traceback
+ print 'Execution raised exception:', traceback.format_exc()
+ return (-1, '')
+
+def main():
+ revision = sys.argv[1]
+ build_dir = sys.argv[2]
+ target_dir = sys.argv[3]
+ bucket = os.environ[BUILDER_NAME].replace('linux', 'lucid64')
+ return DownloadArchive(bucket, revision, build_dir, target_dir)
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698