def METHOD_NAME(command_args, halt_if_fail=True, capture_output=False, working_dir=None):
    """Execute the given command.
    If capture_output is true, then return the output (and ignore the halt_if_fail argument).
    If capture_output is not true, return the return code of the subprocess call (0 for success).
    """
    if working_dir is not None:
        print("Executing in %s: %s" % (working_dir, command_args))
    else:
        print("Executing: %s" % (command_args))
    args = shlex.split(command_args) if isinstance(command_args, str) else command_args
    if capture_output:
        process = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=working_dir)
        out = process.communicate()[0]
        process.wait()
        return out
    else:
        result = subprocess.call(args, cwd=working_dir)
        if halt_if_fail and result:
            raise Exception(
                "Error %s while executing %s in %s" % (result, args, working_dir)
            )
        return result