diff options
author | Victor Stinner <vstinner@python.org> | 2022-01-23 03:03:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-23 03:03:43 (GMT) |
commit | b0898f4aa90d9397e23aef98a2d6b82445ee7455 (patch) | |
tree | 560d6e8e1e438c2b1debf19880f119f9afd79494 | |
parent | 7ad52d174a12951d260aecfcdfe0fcfd2437a66b (diff) | |
download | cpython-b0898f4aa90d9397e23aef98a2d6b82445ee7455.zip cpython-b0898f4aa90d9397e23aef98a2d6b82445ee7455.tar.gz cpython-b0898f4aa90d9397e23aef98a2d6b82445ee7455.tar.bz2 |
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.
-rw-r--r-- | Lib/test/pythoninfo.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 9d733c5..cfd7ac2 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -729,6 +729,45 @@ def collect_windows(info_add): except (ImportError, AttributeError): 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): try: |