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

Unified Diff: gclient_utils.py

Issue 1156743008: Add experimental support for python in 'git cl format' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « .style.yapf ('k') | git_cache.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index fbcbc262b2b1abe490026d054e4216055892f254..21c44c36a786bc5f9e6b84a3ccef0b9b2f5cc84a 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -698,6 +698,8 @@ def GetBuildtoolsPath():
return override
primary_solution = GetPrimarySolutionPath()
+ if not primary_solution:
+ return None
buildtools_path = os.path.join(primary_solution, 'buildtools')
if not os.path.exists(buildtools_path):
# Buildtools may be in the gclient root.
@@ -1171,6 +1173,7 @@ def NumLocalCpus():
logging.debug('Failed to get CPU count. Defaulting to 1.')
return 1
+
def DefaultDeltaBaseCacheLimit():
"""Return a reasonable default for the git config core.deltaBaseCacheLimit.
@@ -1183,6 +1186,7 @@ def DefaultDeltaBaseCacheLimit():
else:
return '512m'
+
def DefaultIndexPackConfig(url=''):
"""Return reasonable default values for configuring git-index-pack.
@@ -1193,3 +1197,21 @@ def DefaultIndexPackConfig(url=''):
if url in THREADED_INDEX_PACK_BLACKLIST:
result.extend(['-c', 'pack.threads=1'])
return result
+
+
+def FindExecutable(executable):
+ """This mimics the "which" utility."""
+ path_folders = os.environ.get('PATH').split(os.pathsep)
+
+ for path_folder in path_folders:
+ target = os.path.join(path_folder, executable)
+ # Just incase we have some ~/blah paths.
+ target = os.path.abspath(os.path.expanduser(target))
+ if os.path.isfile(target) and os.access(target, os.X_OK):
+ return target
+ if sys.platform.startswith('win'):
+ for suffix in ('.bat', '.cmd', '.exe'):
+ alt_target = target + suffix
+ if os.path.isfile(alt_target) and os.access(alt_target, os.X_OK):
+ return alt_target
+ return None
« no previous file with comments | « .style.yapf ('k') | git_cache.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698