# certbot.compat.misc module

This compat module handles various platform specific calls that do not fall into one particular category.

certbot.compat.misc.raise_for_non_administrative_windows_rights() → None

  On Windows, raise if current shell does not have the administrative rights. Do nothing on Linux.

  Raises:

    .errors.Error – If the current shell does not have administrative rights on Windows.

certbot.compat.misc.prepare_virtual_console() → None

  On Windows, ensure that Console Virtual Terminal Sequences are enabled.

certbot.compat.misc.readline_with_timeout(timeout: float, prompt: str | None) → str

  Read user input to return the first line entered, or raise after specified timeout.

  Parameters:

    - timeout (float) – The timeout in seconds given to the user.

    - prompt (str) – The prompt message to display to the user.

  Returns:

    The first line entered by the user.

  Return type:

    str

certbot.compat.misc.get_default_folder(folder_type: str) → str

  Return the relevant default folder for the current OS

  Parameters:

    folder_type (str) – The type of folder to retrieve (config, work or logs)

  Returns:

    The relevant default folder.

  Return type:

    str

certbot.compat.misc.underscores_for_unsupported_characters_in_path(path: str) → str

  Replace unsupported characters in path for current OS by underscores. :param str path: the path to normalize :return: the normalized path :rtype: str

certbot.compat.misc.execute_command_status(cmd_name: str, shell_cmd: str, env: dict | None = None) → tuple[int, str, str]
  Run a command:

    - on Linux command will be run by the standard shell selected with subprocess.run(shell=True)

    - on Windows command will be run in a Powershell shell

  This function returns the exit code, and does not log the result and output of the command.

  Parameters:

    - cmd_name (str) – the user facing name of the hook being run

    - shell_cmd (str) – shell command to execute

    - env (dict) – environ to pass into subprocess.run

  Returns:

    `tuple` (`int` returncode, `str` stderr, `str` stdout)