Removed default JSON files and submoduled JSON encoder class
This commit is contained in:
parent
8c180ca285
commit
4a9d1c5e3c
8 changed files with 65 additions and 88 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import logging
|
||||
from .error_sources import ErrorSource
|
||||
|
||||
ERROR_SOURCES = []
|
||||
|
||||
|
|
@ -8,27 +9,35 @@ def trace_config_exceptions():
|
|||
error_sources = []
|
||||
|
||||
from openflexure_microscope.paths import (
|
||||
DEFAULT_CONFIGURATION_FILE_PATH,
|
||||
CONFIGURATION_FILE_PATH,
|
||||
SETTINGS_FILE_PATH,
|
||||
)
|
||||
|
||||
try:
|
||||
default_config = json.load(DEFAULT_CONFIGURATION_FILE_PATH)
|
||||
default_config = json.load(CONFIGURATION_FILE_PATH)
|
||||
if not default_config:
|
||||
error_sources.append("default_config_empty")
|
||||
error_sources.append(ErrorSource(
|
||||
"Configuration file is missing or empty. This may occur if the server has never been started."
|
||||
))
|
||||
except Exception as e: # pylint: disable=W0703
|
||||
logging.error("Error parsing config:")
|
||||
logging.error(e)
|
||||
error_sources.append("default_config_error")
|
||||
error_sources.append(ErrorSource(
|
||||
f"Configuration file is malformed. You can reset to the default configuration by deleting {CONFIGURATION_FILE_PATH}."
|
||||
))
|
||||
|
||||
try:
|
||||
default_settings = json.load(SETTINGS_FILE_PATH)
|
||||
if not default_settings:
|
||||
error_sources.append("default_settings_empty")
|
||||
error_sources.append(ErrorSource(
|
||||
"Settings file is missing or empty. This may occur if the server has never been started."
|
||||
))
|
||||
except Exception as e: # pylint: disable=W0703
|
||||
logging.error("Error parsing settings:")
|
||||
logging.error(e)
|
||||
error_sources.append("default_settings_error")
|
||||
error_sources.append(ErrorSource(
|
||||
f"Settings file is malformed. You can reset to the default settings by deleting {SETTINGS_FILE_PATH}."
|
||||
))
|
||||
|
||||
return error_sources
|
||||
|
||||
|
|
@ -39,7 +48,9 @@ def main():
|
|||
try:
|
||||
from openflexure_microscope import config as _
|
||||
except Exception as e: # pylint: disable=W0703
|
||||
error_sources.append("config_settings_import_error")
|
||||
error_sources.append(ErrorSource(
|
||||
"Error importing configuration submodule. This could be an error in our code."
|
||||
))
|
||||
logging.error("Error importing config:")
|
||||
logging.error(e)
|
||||
error_sources.extend(trace_config_exceptions())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue