Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: check_ctype_wintype_tool.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- - This script checks Python installation, verifies the availability of the ctypes module,
- and checks if the wintypes attribute is available within the ctypes module on a Windows OS.
- Requirements:
- - Python 3.x
- - Windows OS
- - The following modules:
- - sys
- - ctypes
- Functions:
- - check_python_installation():
- Checks Python installation and prints the installed Python version.
- - verify_ctypes_module():
- Verifies if the ctypes module can be imported successfully. If not, prompts to reinstall Python.
- - check_wintypes_attribute():
- Checks if the wintypes attribute is available within the ctypes module and prints its attributes if available.
- Example Output:
- Checking Python installation...
- Python 3.10.6 is installed.
- Verifying ctypes module...
- ctypes module is imported successfully.
- Checking wintypes attribute...
- wintypes attribute is available within ctypes module.
- Attributes:
- ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'CHAR', 'COLORREF', 'DOUBLE', 'DWORD', 'FILETIME',
- 'FLOAT', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH', 'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP',
- 'HENHMETAFILE', 'HFONT', 'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY',
- 'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR', 'HPALETTE', 'HPEN', 'HRGN',
- 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA', 'HWND', 'INT', 'LANGID', 'LARGE_INTEGER', 'LCID',
- 'LCTYPE', 'LGRPID', 'LONG', 'LPARAM', 'LPBOOL', 'LPBYTE', 'LPCOLESTR', 'LPCOLORREF',
- 'LPCSTR', 'LPCVOID', 'LPCWSTR', 'LPDWORD', 'LPFILETIME', 'LPHANDLE', 'LPHKL', 'LPINT',
- 'LPLONG', 'LPMSG', 'LPOLESTR', 'LPPOINT', 'LPRECT', 'LPRECTL', 'LPSC_HANDLE', 'LPSIZE',
- 'LPSIZEL', 'LPSTR', 'LPUINT', 'LPVOID', 'LPWIN32_FIND_DATAA', 'LPWIN32_FIND_DATAW',
- 'LPWORD', 'LPWSTR', 'MAX_PATH', 'MSG', 'OLESTR', 'PBOOL', 'PBOOLEAN', 'PBYTE', 'PCHAR',
- 'PDWORD', 'PFILETIME', 'PFLOAT', 'PHANDLE', 'PHKEY', 'PINT', 'PLARGE_INTEGER', 'PLCID',
- 'PLONG', 'PMSG', 'POINT', 'POINTL', 'PPOINT', 'PPOINTL', 'PRECT', 'PRECTL', 'PSHORT',
- 'PSIZE', 'PSIZEL', 'PSMALL_RECT', 'PUINT', 'PULARGE_INTEGER', 'PULONG', 'PUSHORT',
- 'PWCHAR', 'PWIN32_FIND_DATAA', 'PWIN32_FIND_DATAW', 'PWORD', 'RECT', 'RECTL', 'RGB',
- 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT',
- 'ULARGE_INTEGER', 'ULONG', 'USHORT', 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA',
- 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER', '_POINTL',
- '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', '__builtins__', '__cached__', '__doc__',
- '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ctypes', 'tagMSG',
- 'tagPOINT', 'tagRECT', 'tagSIZE']
- Process ended with exit code 0.
- Usage:
- - Run this script in a Python environment.
- Additional Notes:
- - This script is designed to run on Windows OS.
- - Ensure that Python 3.x is installed.
- """
- import sys
- from ctypes import wintypes
- def check_python_installation():
- """
- Check Python installation and print the installed Python version.
- """
- try:
- version = sys.version.split()[0]
- print(f"Python {version} is installed.")
- except Exception as e:
- print(f"Error: {e}")
- def verify_ctypes_module():
- """
- Verify if the ctypes module can be imported successfully.
- If not, prompt to reinstall Python.
- """
- try:
- import ctypes
- print("ctypes module is imported successfully.")
- except ImportError:
- print("ctypes module is not imported. Reinstall Python.")
- def check_wintypes_attribute():
- """
- Check if the wintypes attribute is available within the ctypes module.
- Print its attributes if available.
- """
- try:
- attributes = dir(wintypes)
- print("wintypes attribute is available within ctypes module.")
- print("Attributes:", attributes) # Add this line to print the attributes
- except AttributeError:
- print("wintypes attribute is not found within ctypes module.")
- def main():
- """
- Main function to run checks on Python installation, ctypes module, and wintypes attribute.
- """
- print("Checking Python installation...")
- check_python_installation()
- print("\nVerifying ctypes module...")
- verify_ctypes_module()
- print("\nChecking wintypes attribute...")
- check_wintypes_attribute()
- sys.exit() # Exit the script upon completion
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement