Commit 70437212 authored by Joel Collins's avatar Joel Collins
Browse files

Added classes for error sources

parent 9dab2421
Loading
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -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__":
+2 −1
Original line number Diff line number Diff line
import logging


def main():
    error_sources = []
    logging.info("Attempting to import picamera...")
+36 −0
Original line number Diff line number Diff line
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)
 No newline at end of file