| OLD | NEW |
| 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 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * You need to do a one-time configuration step to access Google Storage. | 91 * You need to do a one-time configuration step to access Google Storage. |
| 92 * Please run this command and follow the instructions: | 92 * Please run this command and follow the instructions: |
| 93 * %s config | 93 * %s config |
| 94 * | 94 * |
| 95 * NOTE: When prompted you can leave "project-id" blank. Just hit enter. | 95 * NOTE: When prompted you can leave "project-id" blank. Just hit enter. |
| 96 ******************************************************************************* | 96 ******************************************************************************* |
| 97 ''' % GSUTIL | 97 ''' % GSUTIL |
| 98 sys.exit(1) | 98 sys.exit(1) |
| 99 | 99 |
| 100 | 100 |
| 101 def get_latest(directory, version_file, latest_pattern, permanent_prefix): | 101 def get_latest(name, directory, version_file, latest_pattern, permanent_prefix): |
| 102 """Get the latest DumpRenderTree or Dartium binary depending on arguments. | 102 """Get the latest DumpRenderTree or Dartium binary depending on arguments. |
| 103 | 103 |
| 104 Args: | 104 Args: |
| 105 directory: target directory (recreated) to install binary | 105 directory: target directory (recreated) to install binary |
| 106 version_file: name of file with the current version stamp | 106 version_file: name of file with the current version stamp |
| 107 latest_pattern: the google store url pattern pointing to the latest binary | 107 latest_pattern: the google store url pattern pointing to the latest binary |
| 108 permanent_prefix: stable google store folder used to download versions | 108 permanent_prefix: stable google store folder used to download versions |
| 109 """ | 109 """ |
| 110 system = platform.system() | 110 system = platform.system() |
| 111 if system == 'Darwin': | 111 if system == 'Darwin': |
| 112 osname = 'mac' | 112 osname = 'mac' |
| 113 elif system == 'Linux': | 113 elif system == 'Linux': |
| 114 osname = 'lucid64' | 114 osname = 'lucid64' |
| 115 else: | 115 else: |
| 116 print >>sys.stderr, ('WARNING: platform "%s" does not support' | 116 print >>sys.stderr, ('WARNING: platform "%s" does not support' |
| 117 'DumpRenderTree for tests') % system | 117 '%s for tests') % (system, name) |
| 118 return 0 | 118 return 0 |
| 119 | 119 |
| 120 ensure_config() | 120 ensure_config() |
| 121 | 121 |
| 122 # Query for the lastest version | 122 # Query for the lastest version |
| 123 pattern = latest_pattern % { 'osname' : osname } | 123 pattern = latest_pattern % { 'osname' : osname } |
| 124 result, out = gsutil('ls', pattern) | 124 result, out = gsutil('ls', pattern) |
| 125 if result == 0: | 125 if result == 0: |
| 126 latest = out.split()[-1] | 126 latest = out.split()[-1] |
| 127 # use permanent link instead, just in case the latest zip entry gets deleted | 127 # use permanent link instead, just in case the latest zip entry gets deleted |
| 128 # while we are downloading it. | 128 # while we are downloading it. |
| 129 latest = (permanent_prefix % { 'osname' : osname } | 129 latest = (permanent_prefix % { 'osname' : osname } |
| 130 + latest[latest.rindex('/'):]) | 130 + latest[latest.rindex('/'):]) |
| 131 else: # e.g. no access | 131 else: # e.g. no access |
| 132 print "Couldn't download DumpRenderTree: %s\n%s" % (pattern, out) | 132 print "Couldn't download %s: %s\n%s" % (name, pattern, out) |
| 133 if not os.path.exists(version_file): | 133 if not os.path.exists(version_file): |
| 134 print "Tests using DumpRenderTree will not work. Please try again later." | 134 print "Tests using %s will not work. Please try again later." % name |
| 135 return 0 | 135 return 0 |
| 136 | 136 |
| 137 # Check if we need to update the file | 137 # Check if we need to update the file |
| 138 if os.path.exists(version_file): | 138 if os.path.exists(version_file): |
| 139 v = open(version_file, 'r').read() | 139 v = open(version_file, 'r').read() |
| 140 if v == latest: | 140 if v == latest: |
| 141 if not in_runhooks(): | 141 if not in_runhooks(): |
| 142 print 'DumpRenderTree is up to date.\nVersion: ' + latest | 142 print name + ' is up to date.\nVersion: ' + latest |
| 143 return 0 # up to date | 143 return 0 # up to date |
| 144 | 144 |
| 145 if os.path.exists(directory): | 145 if os.path.exists(directory): |
| 146 print 'Removing old DumpRenderTree tree %s' % directory | 146 print 'Removing old %s tree %s' % (name, directory) |
| 147 shutil.rmtree(directory) | 147 shutil.rmtree(directory) |
| 148 | 148 |
| 149 # download the zip file to a temporary path, and unzip to the target location | 149 # download the zip file to a temporary path, and unzip to the target location |
| 150 temp_dir = tempfile.mkdtemp() | 150 temp_dir = tempfile.mkdtemp() |
| 151 try: | 151 try: |
| 152 temp_zip = temp_dir + '/drt.zip' | 152 temp_zip = temp_dir + '/drt.zip' |
| 153 # It's nice to show download progress | 153 # It's nice to show download progress |
| 154 gsutil_visible('cp', latest, temp_zip) | 154 gsutil_visible('cp', latest, temp_zip) |
| 155 | 155 |
| 156 result, out = execute_command('unzip', temp_zip, '-d', temp_dir) | 156 result, out = execute_command('unzip', temp_zip, '-d', temp_dir) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 172 | 172 |
| 173 | 173 |
| 174 def main(): | 174 def main(): |
| 175 parser = optparse.OptionParser() | 175 parser = optparse.OptionParser() |
| 176 parser.add_option('--dartium', dest='dartium', | 176 parser.add_option('--dartium', dest='dartium', |
| 177 help='Get latest Dartium', action='store_true', | 177 help='Get latest Dartium', action='store_true', |
| 178 default=False) | 178 default=False) |
| 179 args, _ = parser.parse_args() | 179 args, _ = parser.parse_args() |
| 180 | 180 |
| 181 if args.dartium: | 181 if args.dartium: |
| 182 get_latest(DARTIUM_DIR, DARTIUM_VERSION, | 182 get_latest('Dartium', DARTIUM_DIR, DARTIUM_VERSION, |
| 183 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX) | 183 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX) |
| 184 else: | 184 else: |
| 185 get_latest(DRT_DIR, DRT_VERSION, DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX) | 185 get_latest('DumpRenderTree', DRT_DIR, DRT_VERSION, |
| 186 DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX) |
| 186 | 187 |
| 187 if __name__ == '__main__': | 188 if __name__ == '__main__': |
| 188 sys.exit(main()) | 189 sys.exit(main()) |
| OLD | NEW |