Added classes for error sources

This commit is contained in:
Joel Collins 2020-11-06 12:19:41 +00:00
parent 9dab2421a4
commit 70437212b1
3 changed files with 41 additions and 12 deletions

View file

@ -31,15 +31,7 @@ logger.setLevel(logging.DEBUG)
logging.debug("Testing debug logger. One two one two.")
class bcolors:
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
error_keys = {
@ -49,7 +41,7 @@ error_keys = {
"default_config_error": f"The default configuration file could not be parsed. To fix, consider backing up and deleting your configuration files from {CONFIG_PATHS} to reset the configuration.",
"default_settings_error": f"The default settings file could not be parsed. To fix, consider backing up and deleting your configuration files from {SETTINGS_PATHS} to reset the configuration.",
"capture_rebuild_timeout": f"Capture database rebuilding took a long time. This may not cause catastrophic errors, but rather will cause the server to hang for a while. To fix, consider moving your captures from {DATA_PATHS} to another location.",
"picamera_import_error": "Picamera module could not be imported. Check physical connections to the camera as it may be damaged."
"picamera_import_error": "Picamera module could not be imported. Check physical connections to the camera as it may be damaged.",
}
if __name__ == "__main__":
@ -62,7 +54,7 @@ if __name__ == "__main__":
error_sources.extend(check_settings.main())
error_sources.extend(check_picamera.main())
#error_sources.extend(check_capture_reload.main())
# error_sources.extend(check_capture_reload.main())
if not error_sources:

View file

@ -1,5 +1,6 @@
import logging
def main():
error_sources = []
logging.info("Attempting to import picamera...")
@ -12,4 +13,4 @@ def main():
logging.error(e)
error_sources.append("picamera_import_error")
return error_sources
return error_sources

View file

@ -0,0 +1,36 @@
class bcolors:
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
class Source:
def __init__(self, message):
self._message = message
@property
def message(self):
return self._message
class WarningSource:
def __init__(self, message):
self.message = message
@property
def message(self):
print(bcolors.WARNING + self._message + bcolors.ENDC)
class ErrorSource:
def __init__(self, message):
self.message = message
@property
def message(self):
print(bcolors.FAIL + self._message + bcolors.ENDC)