os.platform
===========

.. py:module:: os.platform

.. autoapi-nested-parse::

   Provides function to detect platform specific information.



Attributes
----------

.. autoapisummary::

   os.platform.KNOWLEDGE_BASE
   os.platform.UNKNOWN
   os.platform.logger


Classes
-------

.. autoapisummary::

   os.platform.Uname
   os.platform.SystemInfo
   os.platform.CPU
   os.platform.OS


Module Contents
---------------

.. py:data:: KNOWLEDGE_BASE

.. py:data:: UNKNOWN
   :value: 'unknown'


.. py:class:: Uname

   Bases: :py:obj:`tuple`


   .. py:attribute:: system


   .. py:attribute:: node


   .. py:attribute:: release


   .. py:attribute:: version


   .. py:attribute:: machine


   .. py:attribute:: processor


.. py:data:: logger

.. 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
      :value: None



   .. py:attribute:: core_number
      :value: 1



   .. py:attribute:: ld_info
      :value: None



   .. py:attribute:: _platform
      :type:  str | None
      :value: None



   .. py:attribute:: _os_version
      :type:  tuple[str, str, str] | None
      :value: None



   .. py:attribute:: _hostname
      :type:  tuple[str, str] | None
      :value: 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:



   .. py:method:: full_os_version() -> str
      :classmethod:



   .. py:method:: hostname() -> tuple[str, str]
      :classmethod:


      Get hostname and associated domain.

      :return: a tuple (hostname, domain)



.. py:class:: CPU

   Bases: :py:obj:`namedtuple`\ (\ :py:obj:`'CPU'`\ , [\ :py:obj:`'name'`\ , :py:obj:`'bits'`\ , :py:obj:`'endian'`\ , :py:obj:`'cores'`\ ]\ )


   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:: __slots__
      :value: ()



   .. py:method:: as_dict() -> dict[str, Any]


   .. 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`\ (\ :py:obj:`'OS'`\ , [\ :py:obj:`'name'`\ , :py:obj:`'version'`\ , :py:obj:`'kernel_version'`\ , :py:obj:`'exeext'`\ , :py:obj:`'dllext'`\ , :py:obj:`'is_bareboard'`\ , :py:obj:`'mode'`\ ]\ )


   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:: __slots__
      :value: ()



   .. py:method:: as_dict() -> dict[str, Any]


   .. 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



