示例#1
0
def main():

    os.environ['METRIXPLUSPLUS_INSTALL_DIR'] = os.path.dirname(
        os.path.abspath(__file__))

    exemode = None
    if len(sys.argv[1:]) != 0:
        exemode = sys.argv[1]
    if exemode != "-R" and exemode != "-D":
        exemode = '-D'  # TODO implement install and release mode
        # inject '-D' or '-R' option
        #profile_args = ['-m', 'cProfile']
        profile_args = []
        exit(
            subprocess.call(
                itertools.chain([sys.executable], profile_args,
                                [sys.argv[0], '-D'], sys.argv[1:])))

    command = ""
    if len(sys.argv[1:]) > 1:
        command = sys.argv[2]

    loader = mpp.internal.loader.Loader()
    mpp_paths = []
    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
    args = loader.load(command, mpp_paths, sys.argv[3:])
    exit_code = loader.run(args)
    loader.unload()
    return exit_code
示例#2
0
def execute_command(command: str, paths, args) -> int:
    loader = mpp.internal.loader.Loader()
    args = loader.load(command, paths, args)
    exit_code = loader.run(args)
    loader.unload()
    return exit_code