black the project with -l 120

This commit is contained in:
lorow 2023-04-09 17:16:23 +02:00
parent 2093f3172a
commit dacb76ba06

View File

@ -33,9 +33,7 @@ class BaseAPIClient:
clean_params = await self._clean_params(params) clean_params = await self._clean_params(params)
if validator and not validator(clean_params): if validator and not validator(clean_params):
raise ValueError( raise ValueError(f"Params for command {command} are required, none provided")
f"Params for command {command} are required, none provided"
)
async with self.session.get( async with self.session.get(
f"{self.tracker_address}/{self.base_endpoint}/{command}/", f"{self.tracker_address}/{self.base_endpoint}/{command}/",
@ -44,15 +42,11 @@ class BaseAPIClient:
await request.read() await request.read()
return request return request
async def post( async def post(self, command: str, data: dict, validator: Optional[Callable] = None):
self, command: str, data: dict, validator: Optional[Callable] = None
):
clean_params = await self._clean_params(data) clean_params = await self._clean_params(data)
if validator and not validator(clean_params): if validator and not validator(clean_params):
raise ValueError( raise ValueError(f"Params for command {command} are required, none provided")
f"Params for command {command} are required, none provided"
)
async with self.session.post( async with self.session.post(
f"{self.tracker_address}/{self.base_endpoint}/{command}/", f"{self.tracker_address}/{self.base_endpoint}/{command}/",
@ -61,15 +55,11 @@ class BaseAPIClient:
await request.read() await request.read()
return request return request
async def delete( async def delete(self, command: str, data: dict, validator: Optional[Callable] = None):
self, command: str, data: dict, validator: Optional[Callable] = None
):
clean_params = await self._clean_params(data) clean_params = await self._clean_params(data)
if validator and not validator(clean_params): if validator and not validator(clean_params):
raise ValueError( raise ValueError(f"Params for command {command} are required, none provided")
f"Params for command {command} are required, none provided"
)
async with self.session.delete( async with self.session.delete(
f"{self.tracker_address}/{self.base_endpoint}/{command}/", f"{self.tracker_address}/{self.base_endpoint}/{command}/",
@ -114,9 +104,7 @@ class OpenIrisClient(BaseAPIClient):
return await self.get("resetConfig") return await self.get("resetConfig")
# we should split this into two separate configs and endpoints and clean them up # we should split this into two separate configs and endpoints and clean them up
async def update_device_settings( async def update_device_settings(self, mdns_config: MDNSConfig, device_config: DeviceConfig):
self, mdns_config: MDNSConfig, device_config: DeviceConfig
):
params = { params = {
"hostname": mdns_config.hostname, "hostname": mdns_config.hostname,
"service": mdns_config.service, "service": mdns_config.service,
@ -140,9 +128,9 @@ class OpenIrisClient(BaseAPIClient):
async def update_camera_settings(self, camera_config: CameraConfig): async def update_camera_settings(self, camera_config: CameraConfig):
params = { params = {
"framesize": camera_config.framesize, "framesize": camera_config.framesize.value if camera_config.framesize else None,
"vflip": camera_config.vflip, "vflip": int(camera_config.vflip) if camera_config.vflip is not None else None,
"hflip": camera_config.hflip, "hflip": int(camera_config.hflip) if camera_config.hflip is not None else None,
"quality": camera_config.quality, "quality": camera_config.quality,
"brightness": camera_config.brightness, "brightness": camera_config.brightness,
} }