
def parse_php_wrapper_output(command_results):
    """Parse output of PHP wrapper around utilities (ftp-migrator, web-stream-downloader), return stdout and stderr

    The PHP wrappers are used for security purpose to run utilities under system user of subscription.
    Wrappers put stdout and stderr of FTP migrator to stdout separated by "\0".
    There is no way to pass stdout/stderr separately due to Plesk limitations -
    "plesk bin extension" mixes them, so we first join them in the wrapper, then spit here.

    :type command_results: parallels.core.runners.entities.ExecutionResults
    :rtype: tuple[str]
    """
    wrapper_stdout_parts = command_results.stdout.split('\0', 1)
    stdout = wrapper_stdout_parts[0]
    if len(wrapper_stdout_parts) > 1:
        stderr = wrapper_stdout_parts[1]
    else:
        stderr = ""

    return stdout, stderr
