(info_add)
| 898 | |
| 899 | |
| 900 | def collect_windows(info_add): |
| 901 | if sys.platform != "win32": |
| 902 | # Code specific to Windows |
| 903 | return |
| 904 | |
| 905 | # windows.RtlAreLongPathsEnabled: RtlAreLongPathsEnabled() |
| 906 | # windows.is_admin: IsUserAnAdmin() |
| 907 | try: |
| 908 | import ctypes |
| 909 | if not hasattr(ctypes, 'WinDLL'): |
| 910 | raise ImportError |
| 911 | except ImportError: |
| 912 | pass |
| 913 | else: |
| 914 | ntdll = ctypes.WinDLL('ntdll') |
| 915 | BOOLEAN = ctypes.c_ubyte |
| 916 | try: |
| 917 | RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled |
| 918 | except AttributeError: |
| 919 | res = '<function not available>' |
| 920 | else: |
| 921 | RtlAreLongPathsEnabled.restype = BOOLEAN |
| 922 | RtlAreLongPathsEnabled.argtypes = () |
| 923 | res = bool(RtlAreLongPathsEnabled()) |
| 924 | info_add('windows.RtlAreLongPathsEnabled', res) |
| 925 | |
| 926 | shell32 = ctypes.windll.shell32 |
| 927 | IsUserAnAdmin = shell32.IsUserAnAdmin |
| 928 | IsUserAnAdmin.restype = BOOLEAN |
| 929 | IsUserAnAdmin.argtypes = () |
| 930 | info_add('windows.is_admin', IsUserAnAdmin()) |
| 931 | |
| 932 | try: |
| 933 | import _winapi |
| 934 | except ImportError: |
| 935 | pass |
| 936 | else: |
| 937 | try: |
| 938 | dll_path = _winapi.GetModuleFileName(sys.dllhandle) |
| 939 | info_add('windows.dll_path', dll_path) |
| 940 | except AttributeError: |
| 941 | pass |
| 942 | |
| 943 | call_func(info_add, 'windows.ansi_code_page', _winapi, 'GetACP') |
| 944 | call_func(info_add, 'windows.oem_code_page', _winapi, 'GetOEMCP') |
| 945 | |
| 946 | # windows.version_caption: "wmic os get Caption,Version /value" command |
| 947 | import subprocess |
| 948 | try: |
| 949 | # When wmic.exe output is redirected to a pipe, |
| 950 | # it uses the OEM code page |
| 951 | proc = subprocess.Popen(["wmic", "os", "get", "Caption,Version", "/value"], |
| 952 | stdout=subprocess.PIPE, |
| 953 | stderr=subprocess.PIPE, |
| 954 | encoding="oem", |
| 955 | text=True) |
| 956 | output, stderr = proc.communicate() |
| 957 | if proc.returncode: |
nothing calls this directly
no test coverage detected
searching dependent graphs…