예제 #1
0
파일: arserver.py 프로젝트: Croolman/arcor2
def main() -> None:

    assert sys.version_info >= (3, 8)

    parser = argparse.ArgumentParser()

    parser.add_argument("-v",
                        "--verbose",
                        help="Increase verbosity.",
                        action="store_const",
                        const=True,
                        default=False)
    parser.add_argument(
        "-d",
        "--debug",
        help="Set logging level to debug.",
        action="store_const",
        const=LogLevel.DEBUG,
        default=LogLevel.INFO,
    )
    parser.add_argument("--version",
                        action="version",
                        version=arcor2_arserver.version(),
                        help="Shows version and exits.")
    parser.add_argument("--api_version",
                        action="version",
                        version=arcor2_arserver_data.version(),
                        help="Shows API version and exits.")
    parser.add_argument("-a",
                        "--asyncio_debug",
                        help="Turn on asyncio debug mode.",
                        action="store_const",
                        const=True,
                        default=False)
    parser.add_argument("--openapi",
                        action="store_true",
                        help="Prints OpenAPI models and exits.")

    args = parser.parse_args()

    if args.openapi:
        print_openapi_models()
        return

    glob.logger.level = args.debug
    glob.VERBOSE = args.verbose

    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=args.asyncio_debug)

    compile_json_schemas()

    if os.path.exists(settings.URDF_PATH):
        shutil.rmtree(settings.URDF_PATH)
    os.makedirs(settings.URDF_PATH)

    run(aio_main(), loop=loop, stop_on_unhandled_errors=True)

    shutil.rmtree(settings.OBJECT_TYPE_PATH)
예제 #2
0
파일: arserver.py 프로젝트: robofit/arcor2
async def system_info_cb(req: srpc.c.SystemInfo.Request, ui: WsClient) -> srpc.c.SystemInfo.Response:

    resp = srpc.c.SystemInfo.Response()
    resp.data = resp.Data(
        arcor2_arserver.version(),
        arcor2_arserver_data.version(),
        known_parameter_types(),
        {key for key in RPC_DICT.keys()},
    )
    return resp
예제 #3
0
파일: arserver.py 프로젝트: NelaMm/arcor2
def print_openapi_models() -> None:

    modules = [arcor2_execution_data.events, events]

    for _, mod in inspect.getmembers(evts, inspect.ismodule):
        modules.append(mod)

    event_types: List[Type[events.Event]] = []

    for mod in modules:
        for _, cls in inspect.getmembers(mod, inspect.isclass):
            if issubclass(cls, events.Event):
                event_types.append(cls)

    print(
        models.generate_openapi("ARCOR2 ARServer", arcor2_arserver.version(),
                                [v[0] for k, v in RPC_DICT.items()],
                                event_types))