Esempio n. 1
0
def muterun(command):
    try:
        from Naked.toolshed.types import NakedObject
        response_obj = NakedObject()
        response = subprocess.check_output(command,
                                           stderr=subprocess.STDOUT,
                                           shell=True)
        response_obj.stdout = response
        response_obj.exitcode = 0
        response_obj.stderr = b""
        return response_obj
    except subprocess.CalledProcessError as cpe:
        response_obj.stdout = b""
        response_obj.stderr = cpe.output
        if cpe.returncode:
            response_obj.exitcode = cpe.returncode
        else:
            response_obj.exitcode = 1
        return response_obj
    except Exception as e:
        if DEBUG_FLAG:
            sys.stderr.write(
                "Naked Framework Error: unable to run the shell command with the mute_run() function (Naked.toolshed.shell.py)."
            )
        raise e
Esempio n. 2
0
def muterun(command):
    try:
        from Naked.toolshed.types import NakedObject
        response_obj = NakedObject()
        response = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
        response_obj.stdout = response
        response_obj.exitcode = 0
        response_obj.stderr = b""
        return response_obj
    except subprocess.CalledProcessError as cpe:
        response_obj.stdout = b""
        response_obj.stderr = cpe.output
        if cpe.returncode:
            response_obj.exitcode = cpe.returncode
        else:
            response_obj.exitcode = 1
        return response_obj
    except Exception as e:
        if DEBUG_FLAG:
            sys.stderr.write("Naked Framework Error: unable to run the shell command with the mute_run() function (Naked.toolshed.shell.py).")
        raise e