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

Side by Side Diff: tools/get_drt.py

Issue 10224006: Make get_drt.py work in Windows. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/perf_testing/run_perf_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is 7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is
8 # used for running browser tests of client applications. 8 # used for running browser tests of client applications.
9 9
10 import optparse 10 import optparse
11 import os 11 import os
12 import platform 12 import platform
13 import shutil 13 import shutil
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 import tempfile 16 import tempfile
17 import zipfile
17 18
18 def NormJoin(path1, path2): 19 def NormJoin(path1, path2):
19 return os.path.normpath(os.path.join(path1, path2)) 20 return os.path.normpath(os.path.join(path1, path2))
20 21
21 # Change into the dart directory as we want the project to be rooted here. 22 # Change into the dart directory as we want the project to be rooted here.
22 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir) 23 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir)
23 os.chdir(dart_src) 24 os.chdir(dart_src)
24 25
25 GSUTIL_DIR = 'third_party/gsutil' 26 GSUTIL_DIR = os.path.join('third_party', 'gsutil')
26 GSUTIL = GSUTIL_DIR + '/gsutil' 27 GSUTIL = GSUTIL_DIR + '/gsutil'
27 28
28 DRT_DIR = 'client/tests/drt' 29 DRT_DIR = os.path.join('client', 'tests', 'drt')
29 DRT_VERSION = DRT_DIR + '/LAST_VERSION' 30 DRT_VERSION = os.path.join(DRT_DIR, 'LAST_VERSION')
30 DRT_LATEST_PATTERN = ( 31 DRT_LATEST_PATTERN = (
31 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip') 32 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip')
32 DRT_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc' 33 DRT_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc'
33 34
34 DARTIUM_DIR = 'client/tests/dartium' 35 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium')
35 DARTIUM_VERSION = DARTIUM_DIR + '/LAST_VERSION' 36 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION')
36 DARTIUM_LATEST_PATTERN = ( 37 DARTIUM_LATEST_PATTERN = (
37 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip') 38 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip')
38 DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/dartium-%(osname)s-inc' 39 DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/dartium-%(osname)s-inc'
39 40
40 sys.path.append(GSUTIL_DIR + '/boto') 41 sys.path.append(os.path.join(GSUTIL_DIR, 'boto'))
41 import boto 42 import boto
42 43
43 44
44 def execute_command(*cmd): 45 def execute_command(*cmd):
45 """Execute a command in a subprocess.""" 46 """Execute a command in a subprocess."""
46 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 47 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
47 output, error = pipe.communicate() 48 output, error = pipe.communicate()
48 return pipe.returncode, output 49 return pipe.returncode, output
49 50
50 51
51 def execute_command_visible(*cmd): 52 def execute_command_visible(*cmd):
52 """Execute a command in a subprocess, but show stdout/stderr.""" 53 """Execute a command in a subprocess, but show stdout/stderr."""
53 result = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr, 54 result = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr,
54 stdin=sys.stdin) 55 stdin=sys.stdin)
55 if result != 0: 56 if result != 0:
56 raise Exception('Execution of "%s" failed' % ' '.join(cmd)) 57 raise Exception('Execution of "%s" failed' % ' '.join(cmd))
57 58
58 59
59 def gsutil(*cmd): 60 def gsutil(*cmd):
60 return execute_command(GSUTIL, *cmd) 61 return execute_command('python', GSUTIL, *cmd)
61 62
62 63
63 def gsutil_visible(*cmd): 64 def gsutil_visible(*cmd):
64 execute_command_visible(GSUTIL, *cmd) 65 execute_command_visible('python', GSUTIL, *cmd)
65 66
66 67
67 def has_boto_config(): 68 def has_boto_config():
68 """Returns true if boto config exists.""" 69 """Returns true if boto config exists."""
69 70
70 config_paths = boto.pyami.config.BotoConfigLocations 71 config_paths = boto.pyami.config.BotoConfigLocations
71 if 'AWS_CREDENTIAL_FILE' in os.environ: 72 if 'AWS_CREDENTIAL_FILE' in os.environ:
72 config_paths.append(os.environ['AWS_CREDENTIAL_FILE']) 73 config_paths.append(os.environ['AWS_CREDENTIAL_FILE'])
73 for config_path in config_paths: 74 for config_path in config_paths:
74 if os.path.exists(config_path): 75 if os.path.exists(config_path):
(...skipping 30 matching lines...) Expand all
105 directory: target directory (recreated) to install binary 106 directory: target directory (recreated) to install binary
106 version_file: name of file with the current version stamp 107 version_file: name of file with the current version stamp
107 latest_pattern: the google store url pattern pointing to the latest binary 108 latest_pattern: the google store url pattern pointing to the latest binary
108 permanent_prefix: stable google store folder used to download versions 109 permanent_prefix: stable google store folder used to download versions
109 """ 110 """
110 system = platform.system() 111 system = platform.system()
111 if system == 'Darwin': 112 if system == 'Darwin':
112 osname = 'mac' 113 osname = 'mac'
113 elif system == 'Linux': 114 elif system == 'Linux':
114 osname = 'lucid64' 115 osname = 'lucid64'
116 elif system == 'Windows':
117 osname = 'win'
115 else: 118 else:
116 print >>sys.stderr, ('WARNING: platform "%s" does not support' 119 print >>sys.stderr, ('WARNING: platform "%s" does not support'
117 '%s for tests') % (system, name) 120 '%s for tests') % (system, name)
118 return 0 121 return 0
119 122
120 ensure_config() 123 ensure_config()
121 124
122 # Query for the lastest version 125 # Query for the lastest version
123 pattern = latest_pattern % { 'osname' : osname } 126 pattern = latest_pattern % { 'osname' : osname }
124 result, out = gsutil('ls', pattern) 127 result, out = gsutil('ls', pattern)
(...skipping 17 matching lines...) Expand all
142 print name + ' is up to date.\nVersion: ' + latest 145 print name + ' is up to date.\nVersion: ' + latest
143 return 0 # up to date 146 return 0 # up to date
144 147
145 if os.path.exists(directory): 148 if os.path.exists(directory):
146 print 'Removing old %s tree %s' % (name, directory) 149 print 'Removing old %s tree %s' % (name, directory)
147 shutil.rmtree(directory) 150 shutil.rmtree(directory)
148 151
149 # download the zip file to a temporary path, and unzip to the target location 152 # download the zip file to a temporary path, and unzip to the target location
150 temp_dir = tempfile.mkdtemp() 153 temp_dir = tempfile.mkdtemp()
151 try: 154 try:
152 temp_zip = temp_dir + '/drt.zip' 155 temp_zip = os.path.join(temp_dir, 'drt.zip')
156 temp_zip_url = 'file://' + temp_zip
153 # It's nice to show download progress 157 # It's nice to show download progress
154 gsutil_visible('cp', latest, temp_zip) 158 gsutil_visible('cp', latest, temp_zip_url)
155 159
156 result, out = execute_command('unzip', temp_zip, '-d', temp_dir) 160 z = zipfile.ZipFile(temp_zip)
157 if result != 0: 161 z.extractall(temp_dir)
158 raise Exception('Execution of "unzip %s -d %s" failed: %s' % 162 # remove .zip for dir name
159 (temp_zip, temp_dir, str(out))) 163 unzipped_dir = os.path.join(temp_dir, os.path.basename(latest)[:-4])
160 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-4] # remove .zip 164 z.close()
161 shutil.move(unzipped_dir, directory) 165 shutil.move(unzipped_dir, directory)
162 finally: 166 finally:
163 shutil.rmtree(temp_dir) 167 shutil.rmtree(temp_dir)
164 168
165 # create the version stamp 169 # create the version stamp
166 v = open(version_file, 'w') 170 v = open(version_file, 'w')
167 v.write(latest) 171 v.write(latest)
168 v.close() 172 v.close()
169 173
170 print 'Successfully downloaded to %s' % directory 174 print 'Successfully downloaded to %s' % directory
171 return 0 175 return 0
172 176
173 177
174 def main(): 178 def main():
175 parser = optparse.OptionParser() 179 parser = optparse.OptionParser()
176 parser.add_option('--dartium', dest='dartium', 180 parser.add_option('--dartium', dest='dartium',
177 help='Get latest Dartium', action='store_true', 181 help='Get latest Dartium', action='store_true',
178 default=False) 182 default=False)
179 args, _ = parser.parse_args() 183 args, _ = parser.parse_args()
180 184
181 if args.dartium: 185 if args.dartium:
182 get_latest('Dartium', DARTIUM_DIR, DARTIUM_VERSION, 186 get_latest('Dartium', DARTIUM_DIR, DARTIUM_VERSION,
183 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX) 187 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX)
184 else: 188 else:
185 get_latest('DumpRenderTree', DRT_DIR, DRT_VERSION, 189 get_latest('DumpRenderTree', DRT_DIR, DRT_VERSION,
186 DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX) 190 DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX)
187 191
188 if __name__ == '__main__': 192 if __name__ == '__main__':
189 sys.exit(main()) 193 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/testing/perf_testing/run_perf_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698