mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
[3.10] bpo-45382: test.pythoninfo logs more Windows versions (GH-30891) (GH-30894)
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. (cherry picked from commitb0898f4aa9
) * bpo-45382: test.pythoninfo: set wmic.exe encoding to OEM (GH-30890) (cherry picked from commitcef0a5458f
) (cherry picked from commit4a57fa296b
) Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
ad6ddd8900
commit
0b0609d0d1
1 changed files with 42 additions and 0 deletions
|
@ -719,6 +719,48 @@ def collect_windows(info_add):
|
|||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
import subprocess
|
||||
try:
|
||||
# When wmic.exe output is redirected to a pipe,
|
||||
# it uses the OEM code page
|
||||
proc = subprocess.Popen(["wmic", "os", "get", "Caption,Version", "/value"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
encoding="oem",
|
||||
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):
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue