bpo-45382: test.pythoninfo logs more Windows versions (GH-30817)

Add the following info to test.pythoninfo:

* windows.ver: output of the shell "ver" command
* windows.version and windows.version_caption: output of the
  "wmic os get Caption,Version /value" command.
This commit is contained in:
Victor Stinner 2022-01-23 04:03:43 +01:00 committed by GitHub
parent 7ad52d174a
commit b0898f4aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 0 deletions

View File

@ -729,6 +729,45 @@ def collect_windows(info_add):
except (ImportError, AttributeError): except (ImportError, AttributeError):
pass pass
import subprocess
try:
proc = subprocess.Popen(["wmic", "os", "get", "Caption,Version", "/value"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True)
output, stderr = proc.communicate()
if proc.returncode:
output = ""
except OSError:
pass
else:
for line in output.splitlines():
line = line.strip()
if line.startswith('Caption='):
line = line.removeprefix('Caption=').strip()
if line:
info_add('windows.version_caption', line)
elif line.startswith('Version='):
line = line.removeprefix('Version=').strip()
if line:
info_add('windows.version', line)
try:
proc = subprocess.Popen(["ver"], shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True)
output = proc.communicate()[0]
if proc.returncode:
output = ""
except OSError:
return
else:
output = output.strip()
line = output.splitlines()[0]
if line:
info_add('windows.ver', line)
def collect_fips(info_add): def collect_fips(info_add):
try: try: