Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down