improve error message in OpenHardwareMonitor

pull/7/head
w-e-w 2024-05-19 17:58:33 +09:00
parent 61adc45ccd
commit 38de3a9615
1 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,7 @@
from modules import scripts, shared from modules import scripts, shared, errors
from pathlib import Path from pathlib import Path
import urllib.request import urllib.request
import gradio as gr
import zipfile import zipfile
import launch import launch
import os import os
@ -46,8 +47,7 @@ def init_open_hardware_monitor():
ohm_computer.Open() ohm_computer.Open()
# find the first matching temperature sensor for the specified hardware # find the first matching temperature sensor for the specified hardware
if ohm_sensors is None or shared.opts.gpu_temps_sleep_gpu_name not in str( if ohm_sensors is None or shared.opts.gpu_temps_sleep_gpu_name not in str(ohm_hardware.Name):
ohm_hardware.Name):
for hardware in ohm_computer.Hardware: for hardware in ohm_computer.Hardware:
if shared.opts.gpu_temps_sleep_gpu_name in str(hardware.Name): if shared.opts.gpu_temps_sleep_gpu_name in str(hardware.Name):
for sensor in hardware.Sensors: for sensor in hardware.Sensors:
@ -59,11 +59,13 @@ def init_open_hardware_monitor():
# sensor not found # sensor not found
ohm_sensors = None ohm_sensors = None
ohm_hardware = None ohm_hardware = None
print( error_message = f"OpenHardwareMonitor Couldn't find temperature sensor for {shared.opts.gpu_temps_sleep_gpu_name}"
f"[Error GPU temperature protection] OpenHardwareMonitor Couldn't find temperature sensor for {shared.opts.gpu_temps_sleep_gpu_name}") gr.Warning(error_message)
print(f"[Error GPU temperature protection] {error_message}")
except Exception as e: except Exception as e:
print(f"[Error GPU temperature protection] Failed to initialize OpenHardwareMonitor: {e}") error_message = f"Failed to initialize OpenHardwareMonitor"
errors.report(f'[Error GPU temperature protection] {error_message}')
def get_gpu_temperature_open_hardware_monitor(): def get_gpu_temperature_open_hardware_monitor():