Skip to content
48 changes: 24 additions & 24 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
e))
try:
sys.exit(0)
except:
except Exception:
os._exit(0)

from library.sensors.sensors_python import sensors_fans, is_cpu_fan
Expand Down Expand Up @@ -382,10 +382,10 @@ def __init__(self):

try:
version = open(VERSION_FILE).readline()
except:
except Exception:
try:
version = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8')
except:
except Exception:
version = "0.0.0"

version_label = ttk.Label(self.window, text=version, foreground=DISABLED_TEXT_COLOR)
Expand Down Expand Up @@ -431,7 +431,7 @@ def load_theme_preview(self):
if theme_data and theme_data['display'].get("DISPLAY_SIZE", '3.5"') == _SIZE_2_1_INCH:
# This is a circular screen: apply a circle mask over the preview
theme_preview.paste(circular_mask, mask=circular_mask)
except:
except Exception:
theme_preview = Image.open(MAIN_DIRECTORY / "res/docs/no-preview.png")
finally:
theme_preview.thumbnail((320, 480), Image.Resampling.LANCZOS)
Expand Down Expand Up @@ -460,38 +460,38 @@ def load_config_values(self):

try:
self.theme_cb.set(self.config['config']['THEME'])
except:
except Exception:
self.theme_cb.set("")

self.load_theme_preview()

try:
self.hwlib_cb.set(hw_lib_map[self.config['config']['HW_SENSORS']])
except:
except Exception:
self.hwlib_cb.current(0)

try:
if self.config['config']['ETH'] == "":
self.eth_cb.current(0)
else:
self.eth_cb.set(self.config['config']['ETH'])
except:
except Exception:
self.eth_cb.current(0)

try:
if self.config['config']['WLO'] == "":
self.wl_cb.current(0)
else:
self.wl_cb.set(self.config['config']['WLO'])
except:
except Exception:
self.wl_cb.current(0)

try:
if self.config['config']['COM_PORT'] == "AUTO":
self.com_cb.current(0)
else:
self.com_cb.set(self.config['config']['COM_PORT'])
except:
except Exception:
self.com_cb.current(0)

# Guess display size from theme in the configuration
Expand All @@ -506,32 +506,32 @@ def load_config_values(self):
if size == SIZE_2_x_INCH and self.config['display']['REVISION'] == 'TUR_USB':
size = SIZE_2_8_INCH_NEWREV
self.size_cb.set(size)
except:
except Exception:
self.size_cb.current(0)

# Guess model from revision and size
revision = self.config['display']['REVISION']
try:
self.model_cb.set(revision_and_size_to_model_map[(revision, size)])
except:
except Exception:
self.model_cb.current(0)

try:
self.orient_cb.set(reverse_map[self.config['display']['DISPLAY_REVERSE']])
except:
except Exception:
self.orient_cb.current(0)

try:
self.brightness_slider.set(int(self.config['display']['BRIGHTNESS']))
except:
except Exception:
self.brightness_slider.set(50)

try:
if self.config['config']['CPU_FAN'] == "AUTO":
self.cpu_fan_cb.current(0)
else:
self.cpu_fan_cb.set(self.config['config']['CPU_FAN'])
except:
except Exception:
self.cpu_fan_cb.current(0)

# Reload content on screen
Expand Down Expand Up @@ -602,7 +602,7 @@ def on_theme_editor_click(self):
# Load Python file with local python interpreter (useful for venvs)
theme_editor = next(MAIN_DIRECTORY.glob("theme-editor.py"))
subprocess.Popen([sys.executable, str(theme_editor), self.theme_cb.get()])
except:
except Exception:
# Load binary (for releases) or Python file with system interpreter
theme_editor = next(MAIN_DIRECTORY.glob("theme-editor*"))
if platform.system() == "Windows":
Expand All @@ -620,7 +620,7 @@ def on_saverun_click(self):
# Load Python file with local python interpreter (useful for venvs)
main_file = next(MAIN_DIRECTORY.glob("main.py"))
subprocess.Popen([sys.executable, str(main_file)])
except:
except Exception:
# Load binary (for releases) or Python file with system interpreter
main_file = next(MAIN_DIRECTORY.glob("main*"))
if platform.system() == "Windows":
Expand Down Expand Up @@ -821,7 +821,7 @@ def validateCoord(self, coord: str):
return True
try:
float(coord)
except:
except Exception:
return False
return True

Expand All @@ -836,32 +836,32 @@ def load_config_values(self, config):

try:
self.ping_entry.insert(0, self.config['config']['PING'])
except:
except Exception:
self.ping_entry.insert(0, "8.8.8.8")

try:
self.api_entry.insert(0, self.config['config']['WEATHER_API_KEY'])
except:
except Exception:
pass

try:
self.lat_entry.insert(0, self.config['config']['WEATHER_LATITUDE'])
except:
except Exception:
self.lat_entry.insert(0, "45.75")

try:
self.long_entry.insert(0, self.config['config']['WEATHER_LONGITUDE'])
except:
except Exception:
self.long_entry.insert(0, "45.75")

try:
self.unit_cb.set(weather_unit_map[self.config['config']['WEATHER_UNITS']])
except:
except Exception:
self.unit_cb.set(0)

try:
self.lang_cb.set(weather_lang_map[self.config['config']['WEATHER_LANGUAGE']])
except:
except Exception:
self.lang_cb.set(weather_lang_map["en"])

def citysearch_show_warning(self, warning):
Expand All @@ -880,7 +880,7 @@ def on_search_click(self):
try:
request = requests.get(OPENWEATHER_GEOAPI_URL, timeout=5, params={"appid": api_key, "lang": lang,
"q": city, "limit": 10})
except:
except Exception:
self.citysearch_show_warning("Error fetching OpenWeatherMap Geo API")
return

Expand Down
6 changes: 3 additions & 3 deletions library/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def load_theme():
logger.info("Loading theme %s from %s" % (CONFIG_DATA['config']['THEME'], theme_path / "theme.yaml"))
THEME_DATA = load_yaml(MAIN_DIRECTORY / theme_path / "theme.yaml")
THEME_DATA['PATH'] = str(MAIN_DIRECTORY / theme_path) + "/"
except:
except Exception:
logger.error("Theme not found or contains errors!")
try:
sys.exit(0)
except:
except Exception:
os._exit(0)

copy_default(THEME_DEFAULT, THEME_DATA)
Expand All @@ -76,7 +76,7 @@ def check_theme_compatible(display_size: str):
'THEME'] + " is not compatible with your display revision " + CONFIG_DATA["display"]["REVISION"])
try:
sys.exit(0)
except:
except Exception:
os._exit(0)


Expand Down
2 changes: 1 addition & 1 deletion library/lcd/lcd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def openSerial(self):
f"Configuration again and select the COM port manually")
try:
sys.exit(0)
except:
except Exception:
os._exit(0)

def closeSerial(self):
Expand Down
2 changes: 1 addition & 1 deletion library/lcd/lcd_comm_rev_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _hello(self):
if self.rom_version < 80 or self.rom_version > 100:
logger.warning("ROM version %d may be invalid, use default ROM version 87" % self.rom_version)
self.rom_version = 87
except:
except Exception:
logger.warning("Display returned invalid or unsupported ID, use default ROM version 87")
self.rom_version = 87

Expand Down
2 changes: 1 addition & 1 deletion library/pythoncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def check_python_version():
f"Python {MIN_PYTHON[0]}.{MIN_PYTHON[1]}-{MAX_PYTHON[0]}.{MAX_PYTHON[1]} required on platform {sys.platform}.")
try:
sys.exit(0)
except:
except Exception:
os._exit(0)
16 changes: 8 additions & 8 deletions library/sensors/sensors_librehardwaremonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"config.yaml")
try:
sys.exit(0)
except:
except Exception:
os._exit(0)

handle = Hardware.Computer()
Expand Down Expand Up @@ -201,7 +201,7 @@ def frequency() -> float:
if frequencies:
# Take mean of all core clock as "CPU clock" (as it is done in Windows Task Manager Performance tab)
return mean(frequencies)
except:
except Exception:
pass

# Frequencies reading is not supported on this CPU
Expand Down Expand Up @@ -236,7 +236,7 @@ def temperature() -> float:
if sensor.SensorType == Hardware.SensorType.Temperature and str(sensor.Name).startswith(
"Core") and sensor.Value is not None:
return float(sensor.Value)
except:
except Exception:
pass

return math.nan
Expand All @@ -251,7 +251,7 @@ def fan_percent(fan_name: str = None) -> float:
if sensor.SensorType == Hardware.SensorType.Control and "#2" in str(
sensor.Name) and sensor.Value is not None: # Is Motherboard #2 Fan always the CPU Fan ?
return float(sensor.Value)
except:
except Exception:
pass

# No Fan Speed sensor for this CPU model
Expand Down Expand Up @@ -331,7 +331,7 @@ def fps(cls) -> int:
if int(sensor.Value) > 0:
cls.prev_fps = int(sensor.Value)
return cls.prev_fps
except:
except Exception:
pass

# No FPS sensor for this GPU model
Expand All @@ -348,7 +348,7 @@ def fan_percent(cls) -> float:
for sensor in gpu_to_use.Sensors:
if sensor.SensorType == Hardware.SensorType.Control and sensor.Value is not None:
return float(sensor.Value)
except:
except Exception:
pass

# No Fan Speed sensor for this GPU model
Expand All @@ -367,7 +367,7 @@ def frequency(cls) -> float:
# Keep only real core clocks, ignore effective core clocks
if "Core" in str(sensor.Name) and "Effective" not in str(sensor.Name) and sensor.Value is not None:
return float(sensor.Value)
except:
except Exception:
pass

# No Frequency sensor for this GPU model
Expand Down Expand Up @@ -413,7 +413,7 @@ def swap_percent() -> float:
swap_total = swap_used + swap_available
try:
percent_swap = swap_used / swap_total * 100.0
except:
except Exception:
# No swap / pagefile disabled
percent_swap = 0.0

Expand Down
Loading