feature/multi-robots-types #12
@ -13,6 +13,7 @@ import aiodocker
|
|||||||
import asyncio
|
import asyncio
|
||||||
from spiri_sdk_guitools.video_button import EnableStreamingButton
|
from spiri_sdk_guitools.video_button import EnableStreamingButton
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import importlib.util
|
||||||
|
|
||||||
docker_client = docker.from_env()
|
docker_client = docker.from_env()
|
||||||
|
|
||||||
@ -81,8 +82,17 @@ robot_types = {}
|
|||||||
|
|
||||||
class Robot:
|
class Robot:
|
||||||
def __init_subclass__(self):
|
def __init_subclass__(self):
|
||||||
|
#Register sub-classes as plugins
|
||||||
robot_types[self.robot_type] = self
|
robot_types[self.robot_type] = self
|
||||||
|
|
||||||
|
for file in Path("/robots").glob("**/robot_plugins.py"):
|
||||||
|
logger.info(f"Loading plugin {file}")
|
||||||
|
spec = importlib.util.spec_from_file_location("robot_plugins", file)
|
||||||
|
plugin = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(plugin)
|
||||||
|
logger.info(f"Loaded plugin {file}")
|
||||||
|
|
||||||
|
|
||||||
class Spirimu(Robot):
|
class Spirimu(Robot):
|
||||||
robot_type = "spiri_mu"
|
robot_type = "spiri_mu"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user