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

Side by Side Diff: build/android/pylib/constants.py

Issue 711113002: Add option to specify ADB binary in test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Decided to move where ADB added to path to test_runner.py Created 6 years, 1 month 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
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Defines a set of constants shared by test runners and other scripts.""" 5 """Defines a set of constants shared by test runners and other scripts."""
6 # pylint: disable=W0212 6 # pylint: disable=W0212
7 7
8 import collections 8 import collections
9 import logging 9 import logging
10 import os 10 import os
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 def _Memoize(func): 231 def _Memoize(func):
232 def Wrapper(): 232 def Wrapper():
233 try: 233 try:
234 return func._result 234 return func._result
235 except AttributeError: 235 except AttributeError:
236 func._result = func() 236 func._result = func()
237 return func._result 237 return func._result
238 return Wrapper 238 return Wrapper
239 239
240 240
241 def SetAdbPath(adb_path):
242 os.environ['ADB_PATH'] = adb_path
243
244
245 def GetAdbPath():
jbudorick 2014/11/11 15:27:23 Why is this separate from _FindAdbPath?
mikecase (-- gone --) 2014/11/11 17:56:41 So I can keep the @_Memoize decorator on the logic
jbudorick 2014/11/11 18:04:03 Urgh, we need to rework these "constants." SetAdb
246 # Check if a custom adb path as been set. If not, try to find adb
247 # on the system.
248 if os.environ.get('ADB_PATH'):
249 return os.environ.get('ADB_PATH')
250 else:
251 return _FindAdbPath()
252
253
241 @_Memoize 254 @_Memoize
242 def GetAdbPath(): 255 def _FindAdbPath():
243 if os.environ.get('ANDROID_SDK_ROOT'): 256 if os.environ.get('ANDROID_SDK_ROOT'):
244 return 'adb' 257 return 'adb'
245 # If envsetup.sh hasn't been sourced and there's no adb in the path, 258 # If envsetup.sh hasn't been sourced and there's no adb in the path,
246 # set it here. 259 # set it here.
247 try: 260 try:
248 with file(os.devnull, 'w') as devnull: 261 with file(os.devnull, 'w') as devnull:
249 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) 262 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
250 return 'adb' 263 return 'adb'
251 except OSError: 264 except OSError:
252 logging.debug('No adb found in $PATH, fallback to checked in binary.') 265 logging.debug('No adb found in $PATH, fallback to checked in binary.')
253 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') 266 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
254 267
255
256 # Exit codes 268 # Exit codes
257 ERROR_EXIT_CODE = 1 269 ERROR_EXIT_CODE = 1
258 WARNING_EXIT_CODE = 88 270 WARNING_EXIT_CODE = 88
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698