import argparse import subprocess as sp arg_parser = argparse.ArgumentParser(prog='ucloud', description='Open Source Cloud Management Software') arg_parser.add_argument('component', choices=['api', 'scheduler', 'host', 'filescanner','imagescanner', 'metadata']) arg_parser.add_argument('component_args', nargs='*') args = arg_parser.parse_args() try: command = ['pipenv', 'run', 'python', 'main.py', *args.component_args] sp.run(command, cwd=args.component) except Exception as error: print(error)