Ejemplo n.º 1
0
async def client(
    client: CompanionClient,
    destination: ConnectionDestination,
    metadata: Optional[Dict[str, str]] = None,
) -> ConnectResponse:
    client.logger.debug(f"Connecting to {destination} with meta {metadata}")
    response = await client.stub.connect(
        GrpcConnectRequest(destination=destination_to_grpc(destination),
                           metadata=metadata))
    return companion_to_py(response.companion)
Ejemplo n.º 2
0
def target_to_py(target: GrpcTargetDescription) -> TargetDescription:
    return TargetDescription(
        udid=target.udid,
        name=target.name,
        screen_dimensions=screen_dimensions_to_py(target.screen_dimensions)
        if target.screen_dimensions else None,
        state=target.state,
        target_type=target.target_type,
        os_version=target.os_version,
        architecture=target.architecture,
        companion_info=companion_to_py(target.companion_info)
        if target.companion_info else None,
    )
Ejemplo n.º 3
0
def target_to_py(target: GrpcTargetDescription,
                 companion_info: Optional[CompanionInfo]) -> TargetDescription:
    grpc_companion_info = target.companion_info
    return TargetDescription(
        udid=target.udid,
        name=target.name,
        screen_dimensions=(screen_dimensions_to_py(target.screen_dimensions)
                           if target.screen_dimensions else None),
        state=target.state,
        target_type=target.target_type,
        os_version=target.os_version,
        architecture=target.architecture,
        companion_info=(companion_info if companion_info else companion_to_py(
            grpc_companion_info) if grpc_companion_info else None),
    )