import traceback from iot_api import app from iot_api.user_api import db import werkzeug import marshmallow from flask import jsonify import iot_logging log = iot_logging.getLogger(__name__) # Definition of exception types. In the future more types can be defined. # call as Error.InvalidUsage('This view is gone', status_code=410) class InvalidUsage(Exception): """This class is pretended to use on api responses when the data are invalid. By defaults It return the status_code 400. Example for call: raise InvalidUsage('This view is gone', status_code=410) raise InvalidUsage('This view is gone', status_code=422) """ status_code = 400 def __init__(self, message, status_code=None, payload=None): """Constructor class Args: message (String): The message for return status_code (Integer, optional): Status code HTTP response. Defaults to 400. payload (Dictionary, optional): Payload to return on response. Defaults to None. """ Exception.__init__(self) self.message = message if status_code is not None:
import os, sys from iot_logging import getLogger log = getLogger(__name__) # Pagination MAX_PER_PAGE = 1000 ERROR_OUT = False try: BRAND_NAME = os.environ['BRAND_NAME'] except: BRAND_NAME = "RoLaGuard CE" try: BRAND_URL = os.environ['BRAND_URL'] except: BRAND_URL = "localhost:30000" log.info(f'Using "{BRAND_NAME}" as brand and {BRAND_URL} as URL') # Features try: SEND_EMAILS = True if os.environ['SEND_EMAILS'] == "True" else False except: SEND_EMAILS = False try: ASSIGN_COLLECTOR_TO_USER_ENABLED = True if os.environ[ 'ASSIGN_COLLECTOR_TO_USER_ENABLED'] == "True" else False except: ASSIGN_COLLECTOR_TO_USER_ENABLED = False