Skip to content

azad.system Module

azad.system

Classes

System

System()

System capabilities and configuration singleton.

This class provides information about system capabilities and configuration. It is implemented as a singleton to ensure consistent state across the application.

Initialize system capabilities.

This should only be called once through get_instance().

Source code in azad/system.py
def __init__(self):
    """Initialize system capabilities.

    This should only be called once through get_instance().
    """
    if System._instance is not None:
        raise RuntimeError("Use System.get_instance() instead")

    # Check for /proc system capability, allow override via environment variable
    self._has_proc = False
    has_proc = os.environ.get('AZAD_HAS_PROC', '1') == '1'
    try:
        has_proc_dir = os.path.exists('/proc')
        has_syscall = os.path.exists('/proc/1/syscall')
        if has_proc and has_proc_dir and has_syscall:
            self._has_proc = True
    except OSError:
        pass

    # Detect Python command, allow override via environment variable
    self._python_cmd = os.environ.get('AZAD_PYTHON_CMD') or self._detect_python_command()
Functions
get_instance classmethod
get_instance() -> System

Get the singleton instance.

Source code in azad/system.py
@classmethod
def get_instance(cls) -> System:
    """Get the singleton instance."""
    if cls._instance is None:
        cls._instance = System()
    return cls._instance
has_proc_system
has_proc_system() -> bool

Check if /proc filesystem is available.

Returns:

  • bool ( bool ) –

    True if /proc filesystem is available, False otherwise

Source code in azad/system.py
def has_proc_system(self) -> bool:
    """Check if /proc filesystem is available.

    Returns:
        bool: True if /proc filesystem is available, False otherwise
    """
    return self._has_proc
supports_interactive_tools
supports_interactive_tools() -> bool

Check if the system supports interactive tools.

This requires /proc filesystem support for checking process state. This is an alias for has_proc_system() for backward compatibility.

Returns:

  • bool ( bool ) –

    True if interactive tools are supported, False otherwise

Source code in azad/system.py
def supports_interactive_tools(self) -> bool:
    """Check if the system supports interactive tools.

    This requires /proc filesystem support for checking process state.
    This is an alias for has_proc_system() for backward compatibility.

    Returns:
        bool: True if interactive tools are supported, False otherwise
    """
    return self.has_proc_system()
get_python_command
get_python_command() -> str

Get the Python command to use.

Returns:

  • str ( str ) –

    The Python command to use ('python3' or 'python')

Source code in azad/system.py
def get_python_command(self) -> str:
    """Get the Python command to use.

    Returns:
        str: The Python command to use ('python3' or 'python')
    """
    return self._python_cmd