From f4fee0e31f9b1d351b35b25d1586e6214a5be8fa Mon Sep 17 00:00:00 2001 From: Ace Date: Thu, 18 Jul 2024 01:43:25 +0200 Subject: [PATCH] fix boot folder remapping --- inkycal/main.py | 18 +++++++++++------- inkycal/settings.py | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/inkycal/main.py b/inkycal/main.py index 1275066..cef0e11 100644 --- a/inkycal/main.py +++ b/inkycal/main.py @@ -6,6 +6,7 @@ Copyright by aceinnolab import asyncio import glob import hashlib +import os.path import numpy @@ -72,13 +73,16 @@ class Inkycal: f"No settings.json file could be found in the specified location: {settings_path}") else: - logger.info("Looking for settings.json file in /boot folder...") - try: - with open('/boot/settings.json', mode="r") as settings_file: - self.settings = json.load(settings_file) - - except FileNotFoundError: - raise SettingsFileNotFoundError + found = False + for location in settings.SETTINGS_JSON_PATHS: + if os.path.exists(location): + logger.info(f"Found settings.json file in {location}") + with open(location, mode="r") as settings_file: + self.settings = json.load(settings_file) + found = True + break + if not found: + raise SettingsFileNotFoundError(f"No settings.json file could be found in {settings.SETTINGS_JSON_PATHS} and no explicit path was specified.") self.disable_calibration = self.settings.get('disable_calibration', False) if self.disable_calibration: diff --git a/inkycal/settings.py b/inkycal/settings.py index 9623508..9c4b9dc 100644 --- a/inkycal/settings.py +++ b/inkycal/settings.py @@ -18,3 +18,5 @@ class Settings: PARALLEL_DRIVER_PATH = os.path.join(basedir, "display", "drivers", "parallel_drivers") TEMPORARY_FOLDER = os.path.join(basedir, "tmp") VCOM = "2.0" + # /boot/settings.json is path on older releases, while the latter is more the more recent ones + SETTINGS_JSON_PATHS = ["/boot/settings.json", "/boot/firmware/settings.json"]