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

Unified Diff: build/android/pylib/constants.py

Issue 117333008: Silence warning about falling back to checked-in adb binary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move function closer to use. Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/constants.py
diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants.py
index 9ae9878ebd1a7edd8c72332a813d2f5c1a6d7d5f..a8f284b79f0b5273c48cfb0ce13060d88ea083fe 100644
--- a/build/android/pylib/constants.py
+++ b/build/android/pylib/constants.py
@@ -5,6 +5,7 @@
"""Defines a set of constants shared by test runners and other scripts."""
import collections
+import logging
import os
import subprocess
import sys
@@ -158,7 +159,18 @@ def GetOutDirectory(build_type=None):
GetBuildType() if build_type is None else build_type))
-def _GetADBPath():
+def _Memoize(func):
+ def Wrapper():
+ try:
+ return func._result
+ except AttributeError:
+ func._result = func()
+ return func._result
+ return Wrapper
+
+
+@_Memoize
+def GetAdbPath():
if os.environ.get('ANDROID_SDK_ROOT'):
return 'adb'
# If envsetup.sh hasn't been sourced and there's no adb in the path,
@@ -168,12 +180,10 @@ def _GetADBPath():
subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
return 'adb'
except OSError:
- print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.'
+ logging.debug('No adb found in $PATH, fallback to checked in binary.')
return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
-ADB_PATH = _GetADBPath()
-
# Exit codes
ERROR_EXIT_CODE = 1
WARNING_EXIT_CODE = 88
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698