MCPcopy Create free account
hub / github.com/nodejs/node / _RegistryQueryBase

Function _RegistryQueryBase

tools/gyp/pylib/gyp/MSVSVersion.py:162–189  ·  view source on GitHub ↗

Use reg.exe to read a particular key. While ideally we might use the win32 module, we would like gyp to be python neutral, so for instance cygwin python lacks this module. Arguments: sysdir: The system subdirectory to attempt to launch reg.exe from. key: The registry key to

(sysdir, key, value)

Source from the content-addressed store, hash-verified

160
161
162def _RegistryQueryBase(sysdir, key, value):
163 """Use reg.exe to read a particular key.
164
165 While ideally we might use the win32 module, we would like gyp to be
166 python neutral, so for instance cygwin python lacks this module.
167
168 Arguments:
169 sysdir: The system subdirectory to attempt to launch reg.exe from.
170 key: The registry key to read from.
171 value: The particular value to read.
172 Return:
173 stdout from reg.exe, or None for failure.
174 """
175 # Skip if not on Windows or Python Win32 setup issue
176 if sys.platform not in ("win32", "cygwin"):
177 return None
178 # Setup params to pass to and attempt to launch reg.exe
179 cmd = [os.path.join(os.environ.get("WINDIR", ""), sysdir, "reg.exe"), "query", key]
180 if value:
181 cmd.extend(["/v", value])
182 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
183 # Obtain the stdout from reg.exe, reading to the end so p.returncode is valid
184 # Note that the error text may be in [1] in some cases
185 text = p.communicate()[0].decode("utf-8")
186 # Check return code from reg.exe; officially 0==success and 1==error
187 if p.returncode:
188 return None
189 return text
190
191
192def _RegistryQuery(key, value=None):

Callers 1

_RegistryQueryFunction · 0.85

Calls 4

getMethod · 0.65
decodeMethod · 0.65
joinMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected