Config

Config passes configuration values to servers and other classes as a group. Individual parameters can also be supplied, but using Config is recommended when there are many settings. Use the class directly for one configuration; create instances when multiple independent configurations are needed.

Example config.yaml:

SERVER_IP: "10.170.10.33"
SERVER_PORT: 8000
COBOTTA_IP: "10.170.10.35"
CLIENT_LOGGER_NAME: "Cobotta1_Client"
SERVER_LOGGER_NAME: "Cobotta1_Server"
TIMEOUT: 5
LOGGER_LEVEL: "debug"
COBOTTA_CAMERA_IP: None

Config (class mode)

Use class methods and class variables for a simple configuration.

from cobotta2 import Config
from cobotta2.server import AsyncCobottaClient

Config.load_yaml('cobotta_server.yaml')
print(Config.SERVER_IP)
print(Config.SERVER_PORT)
client = AsyncCobottaClient(config=Config)

Config (instance mode)

from cobotta2 import Config
from cobotta2.server import AsyncCobottaClient, AsyncCobottaStateClient

config = Config("cobotta_server.yaml")
config_state = Config("cobotta_server_sate.yaml")
client = AsyncCobottaClient(config=config)
state = AsyncCobottaStateClient(config=config_state)

Author

  • Kengo NAKADA