8000 bpo-45382: test.pythoninfo logs more Windows versions (GH-30817) · python/cpython@b0898f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit b0898f4

Browse files
authored
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.
1 parent 7ad52d1 commit b0898f4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Lib/test/pythoninfo.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,45 @@ def collect_windows(info_add):
729729
except (ImportError, AttributeError):
730730
pass
731731

732+
import subprocess
733+
try:
734+
proc = subprocess.Popen(["wmic", "os", "get", "Caption,Version", "/value"],
735+
stdout=subprocess.PIPE,
736+
stderr=subprocess.PIPE,
737+
text=True)
738+
output, stderr = proc.communicate()
739+
if proc.returncode:
740+
output = ""
741+
except OSError:
742+
pass
743+
else:
744+
for line in output.splitlines():
745+
line = line.strip()
746+
if line.startswith('Caption='):
747+
line = line.removeprefix('Caption=').strip()
748+
if line:
749+
info_add('windows.version_caption', line)
750+
elif line.startswith('Version='):
751+
line = line.removeprefix('Version=').strip()
752+
if line:
753+
info_add('windows.version', line)
754+
755+
try:
756+
proc = subprocess.Popen(["ver"], shell=True,
757+
stdout=subprocess.PIPE,
758+
stderr=subprocess.PIPE,
759+
text=True)
760+
output = proc.communicate()[0]
761+
if proc.returncode:
762+
output = ""
763+
except OSError:
764+
return
765+
else:
766+
output = output.strip()
767+
line = output.splitlines()[0]
768+
if line:
769+
info_add('windows.ver', line)
770+
732771

733772
def collect_fips(info_add):
734773
try:

0 commit comments

Comments
 (0)
0