diff --git a/src-python/controller.py b/src-python/controller.py index f40a25ae..d5322134 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -1136,7 +1136,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1178,7 +1177,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1203,7 +1201,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1228,7 +1225,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1319,7 +1315,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1360,7 +1355,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1385,7 +1379,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1411,7 +1404,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ diff --git a/src-python/models/osc/osc.py b/src-python/models/osc/osc.py index a47f1f8d..ce64623b 100644 --- a/src-python/models/osc/osc.py +++ b/src-python/models/osc/osc.py @@ -1,4 +1,4 @@ -import asyncio +import time from typing import Any from time import sleep from threading import Thread @@ -120,7 +120,9 @@ class OSCHandler: while True: try: - self.osc_query_service = OSCQueryService(self.osc_query_service_name, self.http_port, self.osc_server_port) + # osc_server_name + UTC timestampでユニークなサービス名を生成 + service_name = f"{self.osc_query_service_name}:{int(time.time())}" + self.osc_query_service = OSCQueryService(service_name, self.http_port, self.osc_server_port) for filter, target in self.dict_filter_and_target.items(): self.osc_query_service.advertise_endpoint(filter, access=OSCAccess.READWRITE_VALUE) break diff --git a/src-python/models/overlay/overlay_image.py b/src-python/models/overlay/overlay_image.py index fec4c741..708ad11c 100644 --- a/src-python/models/overlay/overlay_image.py +++ b/src-python/models/overlay/overlay_image.py @@ -67,9 +67,16 @@ class OverlayImage: font_path = os_path.join(self.root_path, font_family) font = ImageFont.truetype(font_path, font_size) except Exception: - errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) - font = ImageFont.truetype(font_path, font_size) + # overlayフォルダから操作している場合 + if os_path.exists(os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family)): + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + elif os_path.exists(os_path.join(os_path.dirname(__file__), "fonts", font_family)): + # src-pythonフォルダから操作している場合 + font_path = os_path.join(os_path.dirname(__file__), "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + else: + raise FileNotFoundError(f"Font file not found: {font_family}") text_width = draw.textlength(text, font) character_width = text_width // len(text) @@ -171,9 +178,14 @@ class OverlayImage: font_path = os_path.join(self.root_path, font_family) font = ImageFont.truetype(font_path, font_size) except Exception: - errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) - font = ImageFont.truetype(font_path, font_size) + if os_path.exists(os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family)): + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + elif os_path.exists(os_path.join(os_path.dirname(__file__), "fonts", font_family)): + font_path = os_path.join(os_path.dirname(__file__), "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + else: + raise FileNotFoundError(f"Font file not found: {font_family}") # 改行を含んだtextの最大の文字数を計算する text_width = max(draw.textlength(line, font) for line in text.split("\n")) @@ -207,9 +219,16 @@ class OverlayImage: font_path = os_path.join(self.root_path, self.LANGUAGES["Default"]) font = ImageFont.truetype(font_path, font_size) except Exception: - errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"]) - font = ImageFont.truetype(font_path, font_size) + # overlayフォルダから操作している場合 + if os_path.exists(os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"])): + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"]) + font = ImageFont.truetype(font_path, font_size) + elif os_path.exists(os_path.join(os_path.dirname(__file__), "fonts", self.LANGUAGES["Default"])): + # src-pythonフォルダから操作している場合 + font_path = os_path.join(os_path.dirname(__file__), "fonts", self.LANGUAGES["Default"]) + font = ImageFont.truetype(font_path, font_size) + else: + raise FileNotFoundError(f"Font file not found: {self.LANGUAGES['Default']}") text_height = font_size + ui_padding text_width = draw.textlength(date_time, font)