:py:mod:`os.platform` ===================== .. py:module:: os.platform .. autoapi-nested-parse:: Provides function to detect platform specific information. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: os.platform.Uname os.platform.SystemInfo os.platform.CPU os.platform.OS Attributes ~~~~~~~~~~ .. autoapisummary:: os.platform.KNOWLEDGE_BASE os.platform.UNKNOWN os.platform.logger os.platform.WINDOWS_VERSION_VISTA os.platform.WINDOWS_VERSION_8_1 os.platform.WINDOWS_VERSION_10 os.platform.WINDOWS_BUILD_2016 os.platform.WINDOWS_BUILD_2019 os.platform.WINDOWS_BUILD_2022 os.platform.WINDOWS_BUILD_11 .. py:data:: KNOWLEDGE_BASE .. py:data:: UNKNOWN :value: 'unknown' .. py:class:: Uname Bases: :py:obj:`NamedTuple` System uname information. .. py:attribute:: system :type: str .. py:attribute:: node :type: str .. py:attribute:: release :type: str .. py:attribute:: version :type: str .. py:attribute:: machine :type: str .. py:attribute:: processor :type: str .. py:data:: logger .. py:data:: WINDOWS_VERSION_VISTA :value: 6.2 .. py:data:: WINDOWS_VERSION_8_1 :value: 6.3 .. py:data:: WINDOWS_VERSION_10 :value: 10.0 .. py:data:: WINDOWS_BUILD_2016 :value: 17763 .. py:data:: WINDOWS_BUILD_2019 :value: 20348 .. py:data:: WINDOWS_BUILD_2022 :value: 26100 .. py:data:: WINDOWS_BUILD_11 :value: 22000 .. py:class:: SystemInfo Gather info about the system. :cvar uname: instance of Uname namedtuple containing the result of ``uname`` system call. :cvar core_number: integer containing the number of processor cores on the machine .. py:attribute:: uname .. py:attribute:: core_number :value: 1 .. py:attribute:: ld_info .. py:attribute:: _platform :type: str | None .. py:attribute:: _os_version :type: tuple[str, str, str] | None .. py:attribute:: _hostname :type: tuple[str, str] | None .. py:method:: reset_cache() -> None :classmethod: Reset SystemInfo cache. .. py:method:: fetch_system_data() -> None :classmethod: Fetch info from the host system. The function should be the only one that use system calls or programs to fetch information from the current system. Overriding this method should be enough for example for testing purposes as all the other methods use information retrieved in this function. The function should set all the class attributes described at the beginning of this class. .. py:method:: platform() -> str :classmethod: Guess platform name. Internal function that guess base on uname system call the current platform :return: the platform name .. py:method:: _get_os_version() -> tuple[str, str, str] :classmethod: Compute all OS version information. :return: a tuple containing os version (maybe partial), kernel version and a full os version. .. py:method:: os_version() -> tuple[str, str] :classmethod: Os version. .. py:method:: full_os_version() -> str :classmethod: Full os version. .. py:method:: hostname() -> tuple[str, str] :classmethod: Get hostname and associated domain. :return: a tuple (hostname, domain) .. py:class:: CPU Bases: :py:obj:`NamedTuple` Object representing a CPU. CPU attributes are: - name: [str] the CPU name - bits: number of bits for the cpu or 'unknown' - endian: big, little, or unknown - cores: number of cores available .. py:attribute:: name :type: str .. py:attribute:: bits :type: int .. py:attribute:: endian :type: str .. py:attribute:: cores :type: int .. py:method:: as_dict() -> dict[str, Any] Serialize object to dictionary representation. .. py:method:: get(name: str, endian: str | None = None, compute_cores: bool = False, cores: int | None = None) -> CPU :classmethod: Initialize CPU instance. :param name: cpu name :param endian: if not None override endianness default settings :param compute_cores: if True compute the number of cores :param cores: if not None force the apparent number of cpu to that value. .. py:class:: OS Bases: :py:obj:`NamedTuple` Object representing an OS. Attributes are: - name: the OS name - version: the OS version - kernel_version: the exact version of the kernel - exeext: the default executable extension (e.g. .exe on Windows) - dllext: the default shared library extension (e.g. .dll on Windows) - is_bareboard: whether the system has an OS or not. .. py:attribute:: name :type: str .. py:attribute:: version :type: str .. py:attribute:: kernel_version :type: str .. py:attribute:: exeext :type: str .. py:attribute:: dllext :type: str .. py:attribute:: is_bareboard :type: bool .. py:attribute:: mode :type: str .. py:method:: as_dict() -> dict[str, Any] Serialize object to dictionary representation. .. py:method:: get(name: str, is_host: bool = False, version: str = UNKNOWN, mode: str = UNKNOWN) -> OS :classmethod: Initialize OS instance. :param name: os name :param is_host: if True the OS instance is for the host system :param version: os version :param mode: os mode