コード例 #1
0
ファイル: execution.py プロジェクト: robofit/arcor2
def main() -> None:

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "-v",
        "--verbose",
        help="Increase output verbosity",
        action="store_const",
        const=LogLevel.DEBUG,
        default=LogLevel.INFO,
    )
    parser.add_argument(
        "--version", action="version", version=arcor2_execution.version(), help="Shows version and exits."
    )
    parser.add_argument(
        "--api_version", action="version", version=arcor2_execution_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
    )

    args = parser.parse_args()
    logger.level = args.verbose

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

    compile_json_schemas()

    run(aio_main(), loop=loop, stop_on_unhandled_errors=True)
コード例 #2
0
ファイル: arserver.py プロジェクト: NelaMm/arcor2
async def _initialize_server() -> None:

    exe_version = await exe.manager_request(
        rpc.common.Version.Request(uuid.uuid4().int))
    assert isinstance(exe_version, rpc.common.Version.Response)
    if not exe_version.result:
        raise Arcor2Exception("Failed to get Execution version.")

    assert exe_version.data is not None
    """
    Following check is especially useful when running server/execution in Docker containers.
    Then it might easily happen that one tries to use different versions together.
    """
    try:
        hlp.check_compatibility(arcor2_execution_data.version(),
                                exe_version.data.version)
    except Arcor2Exception as e:
        raise Arcor2Exception(
            "ARServer/Execution uses different versions of arcor2_execution_data."
        ) from e

    while True:  # wait until Project service becomes available
        try:
            await storage.initialize_module()
            break
        except storage.ProjectServiceException as e:
            glob.logger.error(
                f"Failed to communicate with Project service. {str(e)}")
            await asyncio.sleep(1)

    while True:
        try:
            if await scene_srv.started():
                glob.logger.warn(
                    "Scene already started, attempting to stop it...")
                await scene_srv.stop()
            break
        except scene_srv.SceneServiceException as e:
            glob.logger.error(
                f"Failed to communicate with the Scene service. {str(e)}")
            await asyncio.sleep(1)

    await osa.get_object_types()

    bound_handler = functools.partial(
        ws_server.server,
        logger=glob.logger,
        register=register,
        unregister=unregister,
        rpc_dict=RPC_DICT,
        event_dict=EVENT_DICT,
        verbose=glob.VERBOSE,
    )

    glob.logger.info("Server initialized.")
    await asyncio.wait(
        [websockets.server.serve(bound_handler, "0.0.0.0", glob.PORT)])

    asyncio.create_task(run_lock_notification_worker())
コード例 #3
0
def main() -> None:

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "-d",
        "--debug",
        help="Set logging level to debug.",
        action="store_const",
        const=LogLevel.DEBUG,
        default=LogLevel.DEBUG if env.get_bool("ARCOR2_EXECUTION_DEBUG") else LogLevel.INFO,
    )
    parser.add_argument(
        "--version", action="version", version=arcor2_execution.version(), help="Shows version and exits."
    )
    parser.add_argument(
        "--api_version", action="version", version=arcor2_execution_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=env.get_bool("ARCOR2_EXECUTION_ASYNCIO_DEBUG"),
    )

    args = parser.parse_args()
    logger.level = args.debug

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

    loop.set_exception_handler(ws_server.custom_exception_handler)

    compile_json_schemas()

    run(aio_main(), loop=loop)
コード例 #4
0
ファイル: execution.py プロジェクト: robofit/arcor2
async def _version_cb(req: arcor2_rpc.common.Version.Request, ui: WsClient) -> arcor2_rpc.common.Version.Response:
    resp = arcor2_rpc.common.Version.Response()
    resp.data = resp.Data(arcor2_execution_data.version())
    return resp