HEX
Server: Apache
System: Linux srv.kreative-web.pt 4.18.0-553.8.1.lve.el8.x86_64 #1 SMP Thu Jul 4 16:24:39 UTC 2024 x86_64
User: kevinefranco (1040)
PHP: 8.2.30
Disabled: mail,system,passthru,exec,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,ini_restore
Upload Files
File: //lib/Acronis/PyTools/commands/run_tool.py
import sys
import subprocess
import acrobind
import acrort


def run_tool(argument):
    command = argument['Command']
    wait_timeout = argument.get('Timeout')
    command_line = '{0} -m {1}'.format(sys.executable, command)
    argv = command_line
    if sys.platform != 'win32':
        import shlex
        argv = shlex.split(command_line)

    tool = subprocess.Popen(argv, universal_newlines=True, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (result, stderr) = tool.communicate(timeout=wait_timeout)
    if tool.returncode != 0:
        acrort.common.make_logic_error(stderr).throw()

    return {'stdout': result}


def execute(*args, **kw):
    ctx = acrort.remoting.CommandContext(*args, **kw)
    arg = acrobind.unit2py(ctx.argument)
    return run_tool(arg)