| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 import hashlib | 7 import hashlib |
| 8 import imp | 8 import imp |
| 9 import os | 9 import os |
| 10 import platform |
| 10 import string | 11 import string |
| 11 import subprocess | 12 import subprocess |
| 12 import sys | 13 import sys |
| 13 | 14 |
| 14 DART_DIR = os.path.abspath( | 15 DART_DIR = os.path.abspath( |
| 15 os.path.normpath(os.path.join(__file__, '..', '..', '..'))) | 16 os.path.normpath(os.path.join(__file__, '..', '..', '..'))) |
| 16 | 17 |
| 17 def GetUtils(): | 18 def GetUtils(): |
| 18 '''Dynamically load the tools/utils.py python module.''' | 19 '''Dynamically load the tools/utils.py python module.''' |
| 19 return imp.load_source('utils', os.path.join(DART_DIR, 'tools', 'utils.py')) | 20 return imp.load_source('utils', os.path.join(DART_DIR, 'tools', 'utils.py')) |
| 20 | 21 |
| 21 utils = GetUtils() | |
| 22 | |
| 23 SYSTEM_RENAMES = { | 22 SYSTEM_RENAMES = { |
| 24 'win32': 'windows', | 23 'win32': 'windows', |
| 25 'windows': 'windows', | 24 'windows': 'windows', |
| 26 'win': 'windows', | 25 'win': 'windows', |
| 27 | 26 |
| 28 'linux': 'linux', | 27 'linux': 'linux', |
| 29 'linux2': 'linux', | 28 'linux2': 'linux', |
| 30 'lucid32': 'linux', | 29 'lucid32': 'linux', |
| 31 'lucid64': 'linux', | 30 'lucid64': 'linux', |
| 32 | 31 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 raise Exception("Failed to execute %s." % command) | 214 raise Exception("Failed to execute %s." % command) |
| 216 return (stdout, stderr, p.returncode) | 215 return (stdout, stderr, p.returncode) |
| 217 | 216 |
| 218 class GSUtil(object): | 217 class GSUtil(object): |
| 219 GSUTIL_IS_SHELL_SCRIPT = False | 218 GSUTIL_IS_SHELL_SCRIPT = False |
| 220 GSUTIL_PATH = None | 219 GSUTIL_PATH = None |
| 221 USE_DART_REPO_VERSION = False | 220 USE_DART_REPO_VERSION = False |
| 222 | 221 |
| 223 def _layzCalculateGSUtilPath(self): | 222 def _layzCalculateGSUtilPath(self): |
| 224 if not GSUtil.GSUTIL_PATH: | 223 if not GSUtil.GSUTIL_PATH: |
| 225 buildbot_gsutil = utils.GetBuildbotGSUtilPath() | 224 buildbot_gsutil = '/b/build/scripts/slave/gsutil' |
| 225 if platform.system() == 'Windows': |
| 226 buildbot_gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil' |
| 226 if os.path.isfile(buildbot_gsutil) and not GSUtil.USE_DART_REPO_VERSION: | 227 if os.path.isfile(buildbot_gsutil) and not GSUtil.USE_DART_REPO_VERSION: |
| 227 GSUtil.GSUTIL_IS_SHELL_SCRIPT = True | 228 GSUtil.GSUTIL_IS_SHELL_SCRIPT = True |
| 228 GSUtil.GSUTIL_PATH = buildbot_gsutil | 229 GSUtil.GSUTIL_PATH = buildbot_gsutil |
| 229 else: | 230 else: |
| 230 dart_gsutil = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil') | 231 dart_gsutil = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil') |
| 231 if os.path.isfile(dart_gsutil): | 232 if os.path.isfile(dart_gsutil): |
| 232 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False | 233 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False |
| 233 GSUtil.GSUTIL_PATH = dart_gsutil | 234 GSUtil.GSUTIL_PATH = dart_gsutil |
| 234 elif GSUtil.USE_DART_REPO_VERSION: | 235 elif GSUtil.USE_DART_REPO_VERSION: |
| 235 raise Exception("Dart repository version of gsutil required, " | 236 raise Exception("Dart repository version of gsutil required, " |
| 236 "but not found.") | 237 "but not found.") |
| 237 else: | 238 else: |
| 238 # We did not find gsutil, look in path | 239 # We did not find gsutil, look in path |
| 239 possible_locations = list(os.environ['PATH'].split(os.pathsep)) | 240 possible_locations = list(os.environ['PATH'].split(os.pathsep)) |
| 240 for directory in possible_locations: | 241 for directory in possible_locations: |
| 241 location = os.path.join(directory, 'gsutil') | 242 location = os.path.join(directory, 'gsutil') |
| 242 if os.path.isfile(location): | 243 if os.path.isfile(location): |
| 243 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False | 244 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False |
| 244 GSUtil.GSUTIL_PATH = location | 245 GSUtil.GSUTIL_PATH = location |
| 245 break | 246 break |
| 246 assert GSUtil.GSUTIL_PATH | 247 assert GSUtil.GSUTIL_PATH |
| 247 | 248 |
| 248 def execute(self, gsutil_args): | 249 def execute(self, gsutil_args): |
| 249 self._layzCalculateGSUtilPath() | 250 self._layzCalculateGSUtilPath() |
| 250 | 251 |
| 251 env = dict(os.environ) | 252 env = dict(os.environ) |
| 252 # If we're on the buildbot, we use a specific boto file. | 253 # If we're on the buildbot, we use a specific boto file. |
| 253 if utils.GetUserName() == 'chrome-bot': | 254 user_name = os.environ.get( |
| 255 'USERNAME' if sys.platform == 'win32' else 'USER', '') |
| 256 if user_name == 'chrome-bot': |
| 254 boto_config = { | 257 boto_config = { |
| 255 'linux': '/mnt/data/b/build/site_config/.boto', | 258 'Linux': '/mnt/data/b/build/site_config/.boto', |
| 256 'macos': '/Volumes/data/b/build/site_config/.boto', | 259 'Darwin': '/Volumes/data/b/build/site_config/.boto', |
| 257 'win32': r'e:\b\build\site_config\.boto', | 260 'Windows': r'e:\b\build\site_config\.boto', |
| 258 }[utils.GuessOS()] | 261 }[platform.system()] |
| 259 env['AWS_CREDENTIAL_FILE'] = boto_config | 262 env['AWS_CREDENTIAL_FILE'] = boto_config |
| 260 env['BOTO_CONFIG'] = boto_config | 263 env['BOTO_CONFIG'] = boto_config |
| 261 | 264 |
| 262 if GSUtil.GSUTIL_IS_SHELL_SCRIPT: | 265 if GSUtil.GSUTIL_IS_SHELL_SCRIPT: |
| 263 gsutil_command = [GSUtil.GSUTIL_PATH] | 266 gsutil_command = [GSUtil.GSUTIL_PATH] |
| 264 else: | 267 else: |
| 265 gsutil_command = [sys.executable, GSUtil.GSUTIL_PATH] | 268 gsutil_command = [sys.executable, GSUtil.GSUTIL_PATH] |
| 266 | 269 |
| 267 return run(gsutil_command + gsutil_args, env=env, | 270 return run(gsutil_command + gsutil_args, env=env, |
| 268 shell=(GSUtil.GSUTIL_IS_SHELL_SCRIPT and | 271 shell=(GSUtil.GSUTIL_IS_SHELL_SCRIPT and |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 332 |
| 330 return checksum_filename | 333 return checksum_filename |
| 331 | 334 |
| 332 def GetChannelFromName(name): | 335 def GetChannelFromName(name): |
| 333 """Get the channel from the name. Bleeding edge builders don't | 336 """Get the channel from the name. Bleeding edge builders don't |
| 334 have a suffix.""" | 337 have a suffix.""" |
| 335 channel_name = string.split(name, '-').pop() | 338 channel_name = string.split(name, '-').pop() |
| 336 if channel_name in Channel.ALL_CHANNELS: | 339 if channel_name in Channel.ALL_CHANNELS: |
| 337 return channel_name | 340 return channel_name |
| 338 return Channel.BLEEDING_EDGE | 341 return Channel.BLEEDING_EDGE |
| OLD | NEW |