MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / _find_chrome_executable

Function _find_chrome_executable

tools/get_chromedriver.py:16–58  ·  view source on GitHub ↗

Find the Chrome executable path on Linux or macOS.

()

Source from the content-addressed store, hash-verified

14
15
16def _find_chrome_executable():
17 """Find the Chrome executable path on Linux or macOS."""
18 system = platform.system()
19
20 if system == 'Darwin':
21 # macOS standard location
22 paths = [
23 '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
24 ]
25 elif system == 'Linux':
26 # Common Linux executables (Chromium and Google Chrome)
27 paths = [
28 'google-chrome',
29 'google-chrome-stable',
30 'chromium',
31 'chromium-browser',
32 ]
33 else:
34 return None
35
36 for path in paths:
37 try:
38 # Check if the command/path is callable (using 'which' or
39 # direct check)
40 if system == 'Linux':
41 # Use 'which' for common Linux commands/paths
42 result = subprocess.run(
43 ['which', path],
44 capture_output=True,
45 text=True,
46 check=False
47 )
48 if result.returncode == 0:
49 return result.stdout.strip()
50
51 # For macOS, or if 'which' failed/is unavailable, check direct path
52 if os.path.exists(path):
53 return path
54
55 except FileNotFoundError:
56 continue
57
58 return None
59
60
61def read_command_line():

Callers 1

get_chrome_versionFunction · 0.85

Calls 3

systemMethod · 0.80
runMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected