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

Function get_chrome_version

tools/get_chromedriver.py:81–166  ·  view source on GitHub ↗

Get the Chrome version number via OS-specific auto-detection.

()

Source from the content-addressed store, hash-verified

79
80
81def get_chrome_version():
82 """Get the Chrome version number via OS-specific auto-detection."""
83 full_version = None
84
85 if platform.system() == 'Windows':
86 try:
87 import winreg
88
89 def _read_registry(root, key, value):
90 try:
91 with winreg.OpenKey(root, key) as hkey:
92 val, _ = winreg.QueryValueEx(hkey, value)
93 return val
94 except Exception:
95 return None
96
97 keys = [
98 r'SOFTWARE\Google\Chrome\BLBeacon',
99 r'SOFTWARE\Wow6432Node\Google\Chrome\BLBeacon',
100 ]
101 version_str = None
102 for key in keys:
103 version_str = _read_registry(
104 winreg.HKEY_CURRENT_USER, key, 'Version'
105 )
106 if version_str:
107 break
108
109 if not version_str:
110 print(
111 'Error: The Chrome version could not be read '
112 'from the Windows registry.'
113 )
114 sys.exit(1)
115
116 full_version = (
117 version_str.split()[-1].strip()
118 if version_str.split()
119 else version_str.strip()
120 )
121
122 except ImportError:
123 print("Error: The 'winreg' module is required on Windows.")
124 sys.exit(1)
125 except Exception as e:
126 print(f"Error reading Windows registry: {e}")
127 sys.exit(1)
128
129 else:
130 chrome_executable = _find_chrome_executable()
131
132 if not chrome_executable:
133 print(
134 'Error: Could not find the Google Chrome or Chromium '
135 'executable in common locations.'
136 )
137 sys.exit(1)
138

Callers 1

mainFunction · 0.85

Calls 4

_read_registryFunction · 0.85
_find_chrome_executableFunction · 0.85
systemMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected