Resource

class mh_en_exec.resource.Resource(id_, type_, data)

The Resource class contains various data related to resource

Variables
  • id (str) – Resource id

  • type – Resource type

  • data (any) – Resource data. Type of this variable depends on the type variable

Warning

Currently only cv2img type is supported
cv2img: OpenCV image
class mh_en_exec.resource.ResourceManager

Resource manager class. Using this class resources can be accessed.

createResource(data, type_: str, id_: Optional[str] = None, overwrite: bool = False) str

Creates resource.

Parameters
  • data (any) – resource data

  • type (str) – resource type

  • id (str, optional) – resource id. If it’s None id will be generated

  • overwrite (bool, optional) – flag that indicates whether an existing resource will be overwritten

Returns

created resource id

Return type

str

createResourceFromBytes(data: bytes, type_: str, id_: Optional[str] = None, overwrite: bool = False)

Creates resource from bytes.

Parameters
  • data (bytes) – resource data

  • type (str) – resource type

  • id (str, optional) – resource id. If it’s None id will be generated

  • overwrite (bool, optional) – flag that indicates whether an existing resource will be overwritten

Returns

created resource id

Return type

str

classmethod getInstance() mh_en_exec.resource.resource_manager_grpc.ResourceManager

Returns resource manager instance

getResource(id_: str) tuple[str, str, object]

Returns resource data

Parameters

id (str) – resource id

Returns

Resource. Tuple of {id, type, data}. Data depends on the resource type

Return type

tuple[str, str, object]

getResourceBytes(id_: str) tuple[str, str, bytes]

Returns resource data in bytes

Parameters

id (str) – resource id

Returns

Resource. Tuple of {id, type, databytes}

Return type

tuple[str, str, bytes]

isResourceId(id)

Verifies resource id

Parameters

id (str) – resource id

Returns

result. True if id is valid, False if id is invalid

Return type

bool

removeResource(id_: str) bool

Removes resource from resource list

Parameters

id (str) – resource id

Returns

result

Return type

bool

property resources: dict[str, Resource]

Returns resources dictionary

Returns

resources

Return type

dict[str, Resource]