Free Motion Capture for Everyone πβ¨
TypeScript
Fix gui state missing warning (#635)
philipqueen0674dc633547
diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.pyindex 0a179b40..1855bf87 100644--- a/freemocap/gui/qt/main_window/freemocap_main_window.py+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py@@ -114,12 +114,7 @@ class MainWindow(QMainWindow):self._freemocap_data_folder_path = freemocap_data_folder_pathself._pipedream_pings = pipedream_pings- try:- self._gui_state = load_gui_state(get_gui_state_json_path())- logger.info("Successfully loaded previous settings")- except Exception:- logger.info("Failed to find previous GUI settings, using default settings")- self._gui_state = GuiState()+ self._gui_state = load_gui_state(get_gui_state_json_path())self._kill_thread_event = multiprocessing.Event()diff --git a/freemocap/gui/qt/utilities/save_and_load_gui_state.py b/freemocap/gui/qt/utilities/save_and_load_gui_state.pyindex a47d62c3..406ddc6a 100644--- a/freemocap/gui/qt/utilities/save_and_load_gui_state.py+++ b/freemocap/gui/qt/utilities/save_and_load_gui_state.py@@ -22,10 +22,13 @@ class GuiState(BaseModel):def save_gui_state(gui_state: GuiState, file_pathstring: str) -> None:with open(file_pathstring, "w") as file:- json.dump(gui_state.dict(), file, indent=4)+ json.dump(gui_state.model_dump(mode="json"), file, indent=4)def load_gui_state(file_pathstring: str) -> GuiState:- with open(file_pathstring, "r") as file:- gui_state = GuiState(**json.load(file))+ try:+ with open(file_pathstring, "r") as file:+ gui_state = GuiState(**json.load(file))+ except OSError:+ gui_state = GuiState()return gui_statediff --git a/freemocap/system/paths_and_filenames/path_getters.py b/freemocap/system/paths_and_filenames/path_getters.pyindex 8c719b79..2fafdadc 100644--- a/freemocap/system/paths_and_filenames/path_getters.py+++ b/freemocap/system/paths_and_filenames/path_getters.py@@ -63,7 +63,7 @@ def get_freemocap_data_folder_path(create_folder: bool = True) -> str:str(Path(freemocap_data_folder_path) / LOGS_INFO_AND_SETTINGS_FOLDER_NAME / GUI_STATE_JSON_FILENAME))freemocap_data_folder_path = Path(gui_state.freemocap_data_folder_path)- except Exception as e:+ except Exception as e: # TODO: figure out specific exceptions to catchprint(e) # Cannot log this due to circular import from logging configfinally:if freemocap_data_folder_path is None: