Beispiel #1
0
    def __init__(self, error=None, status=500, exception=False):

        # Configuration / logger
        self.conf = config.parse()
        self.log  = logger.create(__name__, self.conf.server.log)

        # Store the response status code
        self.status = status

        # Construct the JSON error object
        self.error_object = {
            'message': ERR_MESSAGE.get(self.status, 'An unknown error has occurred, please contact your administrator'),
            'code':    self.status,
            'error':   error if not isinstance(error, (list, dict)) else json.dumps(error)
        }
        
        # If an error message is provided
        if error and isinstance(error, (str, unicode, basestring)):
            self.log.error(error)
        
        # If providing a stack trace for debugging and debugging is enabled
        if exception and self.conf.server.debug:
            self.error_object.update({
                'debug': self._extract_trace()
            })
Beispiel #2
0
 def __init__(self):
     self.feedback = Feedback()
 
     # Configuration / logger
     self.conf   = config.parse()
     self.log    = logger.create('bootstrap', '{}/bootstrap.log'.format(LOG_DIR))
 
     # Bootstrap parameters
     self.params = BootstrapParams()
 
     # Server configuration file
     self.server_conf = self.params.file['config']['server_conf'][1]
     
     # Database connection
     self._connection = None
Beispiel #3
0
    def __init__(self, child):
        """
        Class constructor.
        
        :param child: Child class object
        :type child: class object
        """
    
        # Define the logger name
        log_name  = '{}.{}'.format(__name__, child.__class__.__name__)

        # Running utilities on the server
        if os.path.isfile(LENSE_CONFIG.SERVER):
            self.conf = config.parse('SERVER')
            self.log  = logger.create(log_name, self.conf.utils.log)
            
        # Raise an exception if neither the server nor agent configuration is found
        else:
            raise Exception('Could not locate the server configuration')
Beispiel #4
0
import ldap
import json

# Django Libraries
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion

# Lense Libraries
import lense.common.config as config

# Configuration
CONFIG = config.parse('SERVER')

class AuthGroupsLDAP(object):
    """
    Construct an LDAPSearchUnion object for every LDAP search group defined.
    """
    
    @staticmethod
    def get_map():
        """
        Load the LDAP JSON map file.
        """
        try:
            return json.load(open(CONFIG.ldap.map))
        
        # Failed to parse JSON map file
        except Exception as e:
            raise Exception('Failed to load LDAP JSON map file [{}]: {}'.format(CONFIG.ldap.map, str(e)))
    
    @staticmethod
    def construct():