👍️[Update] All : 不要なprintLogを削除 / なるべくtry exceptした場合にはerrorLogを保存するように変更

This commit is contained in:
misyaguziya
2024-12-16 23:38:05 +09:00
parent 030b8a9f01
commit 3fa819df3f
14 changed files with 73 additions and 67 deletions

View File

@@ -10,11 +10,7 @@ try:
from . import overlay_utils as utils
except ImportError:
import overlay_utils as utils
try:
from utils import printLog
except ImportError:
def printLog(*args):
print(*args)
from utils import errorLogging
def mat34Id(array):
arr = openvr.HmdMatrix34_t()
@@ -114,8 +110,8 @@ class Overlay:
self.updateFadeoutDuration(self.settings[size]["fadeout_duration"], size)
self.init_process = False
except Exception as e:
printLog("error:Could not initialise OpenVR", e)
except Exception:
errorLogging()
def updateImage(self, img, size):
if self.initialized is True:
@@ -125,8 +121,8 @@ class Overlay:
try:
self.overlay.setOverlayRaw(self.handle[size], img, width, height, 4)
except Exception as e:
printLog("error:Could not update image", e)
except Exception:
errorLogging()
self.initialized = False
self.reStartOverlay()
while self.initialized is False:
@@ -217,8 +213,8 @@ class Overlay:
if new_event.eventType == openvr.VREvent_Quit:
return False
return True
except Exception as e:
printLog("error:Could not check SteamVR running", e)
except Exception:
errorLogging()
return False
def evaluateOpacityFade(self, size):
@@ -344,9 +340,11 @@ if __name__ == "__main__":
overlay.updateImage(img, "small")
time.sleep(15)
except openvr.error_code.OverlayError_InvalidParameter as e:
errorLogging()
logging.error(f"OverlayError_InvalidParameter: {e}")
break
except Exception as e:
errorLogging()
logging.error(f"Unexpected error: {e}")
break

View File

@@ -2,6 +2,7 @@ from os import path as os_path
from datetime import datetime
from typing import Tuple
from PIL import Image, ImageDraw, ImageFont
from utils import errorLogging
class OverlayImage:
LANGUAGES = {
@@ -56,6 +57,7 @@ class OverlayImage:
font_path = os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "fonts", f"{font_family}.ttf")
font = ImageFont.truetype(font_path, font_size)
except Exception:
errorLogging()
font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", f"{font_family}.ttf")
font = ImageFont.truetype(font_path, font_size)
@@ -133,6 +135,7 @@ class OverlayImage:
font_path = os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "fonts", f"{font_family}.ttf")
font = ImageFont.truetype(font_path, font_size)
except Exception:
errorLogging()
font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", f"{font_family}.ttf")
font = ImageFont.truetype(font_path, font_size)
@@ -167,6 +170,7 @@ class OverlayImage:
font_path = os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "fonts", "NotoSansJP-Regular.ttf")
font = ImageFont.truetype(font_path, font_size)
except Exception:
errorLogging()
font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", "NotoSansJP-Regular.ttf")
font = ImageFont.truetype(font_path, font_size)