????

Your IP : 18.119.253.198


Current Path : /proc/thread-self/root/proc/self/root/proc/self/root/lib/Acronis/PyTools/commands/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/proc/self/root/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)