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

Side by Side Diff: tools/bots/bot_utils.py

Issue 289983003: Remove the dependency of tools/bot/bot_utils.py on tools/utils.py (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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 '''Dynamically load the tools/utils.py python module.'''
19 return imp.load_source('utils', os.path.join(DART_DIR, 'tools', 'utils.py'))
20
21 utils = GetUtils()
ricow1 2014/05/15 13:28:38 you can't do this, this is used in many of the oth
Bill Hesse 2014/05/15 13:57:03 OK, I only tested this one. So I'll leave the fun
22
23 SYSTEM_RENAMES = { 18 SYSTEM_RENAMES = {
24 'win32': 'windows', 19 'win32': 'windows',
25 'windows': 'windows', 20 'windows': 'windows',
26 'win': 'windows', 21 'win': 'windows',
27 22
28 'linux': 'linux', 23 'linux': 'linux',
29 'linux2': 'linux', 24 'linux2': 'linux',
30 'lucid32': 'linux', 25 'lucid32': 'linux',
31 'lucid64': 'linux', 26 'lucid64': 'linux',
32 27
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 raise Exception("Failed to execute %s." % command) 210 raise Exception("Failed to execute %s." % command)
216 return (stdout, stderr, p.returncode) 211 return (stdout, stderr, p.returncode)
217 212
218 class GSUtil(object): 213 class GSUtil(object):
219 GSUTIL_IS_SHELL_SCRIPT = False 214 GSUTIL_IS_SHELL_SCRIPT = False
220 GSUTIL_PATH = None 215 GSUTIL_PATH = None
221 USE_DART_REPO_VERSION = False 216 USE_DART_REPO_VERSION = False
222 217
223 def _layzCalculateGSUtilPath(self): 218 def _layzCalculateGSUtilPath(self):
224 if not GSUtil.GSUTIL_PATH: 219 if not GSUtil.GSUTIL_PATH:
225 buildbot_gsutil = utils.GetBuildbotGSUtilPath() 220 buildbot_gsutil = '/b/build/scripts/slave/gsutil'
221 if platform.system() == 'Windows':
222 buildbot_gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil'
226 if os.path.isfile(buildbot_gsutil) and not GSUtil.USE_DART_REPO_VERSION: 223 if os.path.isfile(buildbot_gsutil) and not GSUtil.USE_DART_REPO_VERSION:
227 GSUtil.GSUTIL_IS_SHELL_SCRIPT = True 224 GSUtil.GSUTIL_IS_SHELL_SCRIPT = True
228 GSUtil.GSUTIL_PATH = buildbot_gsutil 225 GSUtil.GSUTIL_PATH = buildbot_gsutil
229 else: 226 else:
230 dart_gsutil = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil') 227 dart_gsutil = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil')
231 if os.path.isfile(dart_gsutil): 228 if os.path.isfile(dart_gsutil):
232 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False 229 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False
233 GSUtil.GSUTIL_PATH = dart_gsutil 230 GSUtil.GSUTIL_PATH = dart_gsutil
234 elif GSUtil.USE_DART_REPO_VERSION: 231 elif GSUtil.USE_DART_REPO_VERSION:
235 raise Exception("Dart repository version of gsutil required, " 232 raise Exception("Dart repository version of gsutil required, "
236 "but not found.") 233 "but not found.")
237 else: 234 else:
238 # We did not find gsutil, look in path 235 # We did not find gsutil, look in path
239 possible_locations = list(os.environ['PATH'].split(os.pathsep)) 236 possible_locations = list(os.environ['PATH'].split(os.pathsep))
240 for directory in possible_locations: 237 for directory in possible_locations:
241 location = os.path.join(directory, 'gsutil') 238 location = os.path.join(directory, 'gsutil')
242 if os.path.isfile(location): 239 if os.path.isfile(location):
243 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False 240 GSUtil.GSUTIL_IS_SHELL_SCRIPT = False
244 GSUtil.GSUTIL_PATH = location 241 GSUtil.GSUTIL_PATH = location
245 break 242 break
246 assert GSUtil.GSUTIL_PATH 243 assert GSUtil.GSUTIL_PATH
247 244
248 def execute(self, gsutil_args): 245 def execute(self, gsutil_args):
249 self._layzCalculateGSUtilPath() 246 self._layzCalculateGSUtilPath()
250 247
251 env = dict(os.environ) 248 env = dict(os.environ)
252 # If we're on the buildbot, we use a specific boto file. 249 # If we're on the buildbot, we use a specific boto file.
253 if utils.GetUserName() == 'chrome-bot': 250 user_name = os.environ.get(
251 'USERNAME' if sys.platform == 'win32' else 'USER', '')
252 if user_name == 'chrome-bot':
254 boto_config = { 253 boto_config = {
255 'linux': '/mnt/data/b/build/site_config/.boto', 254 'Linux': '/mnt/data/b/build/site_config/.boto',
256 'macos': '/Volumes/data/b/build/site_config/.boto', 255 'Darwin': '/Volumes/data/b/build/site_config/.boto',
257 'win32': r'e:\b\build\site_config\.boto', 256 'Windows': r'e:\b\build\site_config\.boto',
258 }[utils.GuessOS()] 257 }[platform.system()]
259 env['AWS_CREDENTIAL_FILE'] = boto_config 258 env['AWS_CREDENTIAL_FILE'] = boto_config
260 env['BOTO_CONFIG'] = boto_config 259 env['BOTO_CONFIG'] = boto_config
261 260
262 if GSUtil.GSUTIL_IS_SHELL_SCRIPT: 261 if GSUtil.GSUTIL_IS_SHELL_SCRIPT:
263 gsutil_command = [GSUtil.GSUTIL_PATH] 262 gsutil_command = [GSUtil.GSUTIL_PATH]
264 else: 263 else:
265 gsutil_command = [sys.executable, GSUtil.GSUTIL_PATH] 264 gsutil_command = [sys.executable, GSUtil.GSUTIL_PATH]
266 265
267 return run(gsutil_command + gsutil_args, env=env, 266 return run(gsutil_command + gsutil_args, env=env,
268 shell=(GSUtil.GSUTIL_IS_SHELL_SCRIPT and 267 shell=(GSUtil.GSUTIL_IS_SHELL_SCRIPT and
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 328
330 return checksum_filename 329 return checksum_filename
331 330
332 def GetChannelFromName(name): 331 def GetChannelFromName(name):
333 """Get the channel from the name. Bleeding edge builders don't 332 """Get the channel from the name. Bleeding edge builders don't
334 have a suffix.""" 333 have a suffix."""
335 channel_name = string.split(name, '-').pop() 334 channel_name = string.split(name, '-').pop()
336 if channel_name in Channel.ALL_CHANNELS: 335 if channel_name in Channel.ALL_CHANNELS:
337 return channel_name 336 return channel_name
338 return Channel.BLEEDING_EDGE 337 return Channel.BLEEDING_EDGE
OLDNEW
« 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