Execute mayapython with the given arguments, capture and return the output

    :param args: arguments for the maya python intepreter
    :type args: list
    :param wait: If True, waits for the process to finish and returns the returncode.
                 If False, just returns the process
    :type wait: bool
    :returns: if wait is True, the returncode, else the process
    :rtype: int|:class:`subprocess.Popen`
    :raises: None

def execute_mayapy(args, wait=True):
    """Execute mayapython with the given arguments, capture and return the output

    :param args: arguments for the maya python intepreter
    :type args: list
    :param wait: If True, waits for the process to finish and returns the returncode.
                 If False, just returns the process
    :type wait: bool
    :returns: if wait is True, the returncode, else the process
    :rtype: int|:class:`subprocess.Popen`
    :raises: None
    """
    osinter = ostool.get_interface()
    mayapy = osinter.get_maya_python()
    allargs = [mayapy]
    allargs.extend(args)
    print "Executing mayapy with: %s" % allargs
    mayapyprocess = subprocess.Popen(allargs)
    if wait:
        rc = mayapyprocess.wait()
        print "Process mayapy finished!"
        return rc
    else:
        return mayapyprocess