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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import os
6 from os import path
7 import sys
8
9
10 # Based on http://stackoverflow.com/questions/377017/test-if-executable-exists-i n-python.
11 def which(program):
12 def is_executable(fpath):
13 return path.isfile(fpath) and os.access(fpath, os.X_OK)
14
15 fpath, fname = path.split(program)
16 if fpath:
17 if is_executable(program):
18 return program
19 return None
20 env_paths = os.environ["PATH"].split(os.pathsep)
21 if sys.platform == "win32":
22 env_paths = get_windows_path(env_paths)
23 for part in env_paths:
24 part = part.strip('\"')
25 file = path.join(part, program)
26 if is_executable(file):
27 return file
28 if sys.platform == "win32" and not file.endswith(".exe"):
29 file_exe = file + ".exe"
30 if is_executable(file_exe):
31 return file_exe
32 return None
33
34
35 # Use to find 64-bit programs (e.g. Java) when using 32-bit python in Windows
36 def get_windows_path(env_paths):
37 new_env_paths = env_paths[:]
38 for env_path in env_paths:
39 env_path = env_path.lower()
40 if "system32" in env_path:
41 new_env_paths.append(env_path.replace("system32", "sysnative"))
42 return new_env_paths
OLDNEW
« 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