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

Unified Diff: third_party/WebKit/Source/devtools/scripts/utils.py

Issue 2554573010: DevTools: fix presubmit hooks for windows (Closed)
Patch Set: include utils.py in BUILD.gn isolate target Created 4 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 | « third_party/WebKit/Source/devtools/scripts/lint_javascript.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/scripts/utils.py
diff --git a/third_party/WebKit/Source/devtools/scripts/utils.py b/third_party/WebKit/Source/devtools/scripts/utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..4ff392ba194c85a741c99830598f571bf61c17e6
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/scripts/utils.py
@@ -0,0 +1,42 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+from os import path
+import sys
+
+
+# Based on http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python.
+def which(program):
+ def is_executable(fpath):
+ return path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+ fpath, fname = path.split(program)
+ if fpath:
+ if is_executable(program):
+ return program
+ return None
+ env_paths = os.environ["PATH"].split(os.pathsep)
+ if sys.platform == "win32":
+ env_paths = get_windows_path(env_paths)
+ for part in env_paths:
+ part = part.strip('\"')
+ file = path.join(part, program)
+ if is_executable(file):
+ return file
+ if sys.platform == "win32" and not file.endswith(".exe"):
+ file_exe = file + ".exe"
+ if is_executable(file_exe):
+ return file_exe
+ return None
+
+
+# Use to find 64-bit programs (e.g. Java) when using 32-bit python in Windows
+def get_windows_path(env_paths):
+ new_env_paths = env_paths[:]
+ for env_path in env_paths:
+ env_path = env_path.lower()
+ if "system32" in env_path:
+ new_env_paths.append(env_path.replace("system32", "sysnative"))
+ return new_env_paths
« no previous file with comments | « third_party/WebKit/Source/devtools/scripts/lint_javascript.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698