Example #1
0
async def system_info_cb(req: rpc.common.SystemInfoRequest,
                         ui: WsClient) -> rpc.common.SystemInfoResponse:

    resp = rpc.common.SystemInfoResponse()
    resp.data.version = arcor2.version()
    resp.data.api_version = arcor2.api_version()
    resp.data.supported_parameter_types = set(PARAM_PLUGINS.keys())
    resp.data.supported_rpc_requests = {key.request for key in RPC_DICT.keys()}
    return resp
Example #2
0
def main():

    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.version(),
                        help="Shows ARCOR2 version and exits.")
    parser.add_argument('--api_version',
                        action='version',
                        version=arcor2.api_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()
    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)
Example #3
0
def main() -> None:

    assert sys.version_info >= (3, 8)

    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.version(),
                        help="Shows ARCOR2 version and exits.")
    parser.add_argument('--api_version',
                        action='version',
                        version=arcor2.api_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)
Example #4
0
from flask_swagger_ui import get_swaggerui_blueprint  # type: ignore

import arcor2
from arcor2.data import common, object_type, services
from arcor2.helpers import camel_case_to_snake_case
from arcor2.rest import convert_keys

PORT = int(os.getenv("ARCOR2_PROJECT_SERVICE_MOCK_PORT", 5012))
SERVICE_NAME = "ARCOR2 Project Service Mock"


# Create an APISpec
spec = APISpec(
    title=SERVICE_NAME,
    version=arcor2.version(),
    openapi_version="3.0.2",
    plugins=[FlaskPlugin(), DataclassesPlugin()],
)

app = Flask(__name__)
CORS(app)


def get_id() -> int:
    return uuid.uuid4().int


SCENES: Dict[str, common.Scene] = {}
PROJECTS: Dict[str, common.Project] = {}
OBJECT_TYPES: Dict[str, object_type.ObjectType] = {}