Ejemplo n.º 1
0
def load_config(**kwargs):
    request_initialize('config', **kwargs)
    request_initialize('logging', **kwargs)
    config.config_amend_(CONFIG_BASE)

    client_options = config.wamp.connection.dict()

    # Going to default to cbor if possible due to the richness of the
    # data types
    try:
        import cbor
        serializers = client_options.get('serializers', ['cbor'])
    except:
        serializers = client_options.get('serializers', ['json'])

    wamp.configure(
        username=client_options.get('username', u''),
        password=client_options.get('password', u''),
        url=client_options.get('url', u'wss://nexus.izaber.com/ws'),
        uri_base=client_options.get('uri_base', u'com.izaber.wamp'),
        realm=client_options.get('realm', u'izaber'),
        authmethods=client_options.get('authmethods', [u'ticket']),
        timeout=client_options.get('timeout', 10),
        serializers=serializers,
    )

    if AUTORUN and config.wamp.get('run', True):
        wamp.run()
Ejemplo n.º 2
0
def my_initialize(**kwargs):

    # We wish to ensure module1 has been initialized before
    # module 2
    request_initialize('module1', **kwargs)

    print("Module 2 about to initialize")
    print(f"Found {len(MYGLOBALVAR.items())} items in module1")
    print("Module 2 initialization complete!")
Ejemplo n.º 3
0
def initialize(**kwargs):
    request_initialize('config', **kwargs)
    logging_config = config.get('logging', {})
    logging_config.update(kwargs.get('logging', {}))

    # Find the best place to put the log
    if 'filename' not in logging_config:
        for log_location in ['/tmp', '/temp', '.']:
            if not os.path.isdir(log_location):
                continue
            logging_config.setdefault('filename',
                                      os.path.join(log_location, 'log.log'))
            break
    logging_config.setdefault('filemode', 'a')
    logging_config.setdefault(
        'format', '%(levelname)s %(asctime)s %(module)s: %(message)s')
    logging_config.setdefault('datefmt', '%Y-%m-%d %H:%M:%S')
    logging_config.setdefault('level', logging.WARNING)

    logging.basicConfig(**logging_config)
Ejemplo n.º 4
0
def load_config(**kwargs):
    request_initialize('config', **kwargs)
    config.config_amend_(CONFIG_BASE)

    request_initialize('logging', **kwargs)
    request_initialize('flask', **kwargs)
    request_initialize('paths', **kwargs)

    # We add the realm when we finally have access
    # to the config (after load). Due to how the flask
    # 'app' variable works, we would need access to config
    # before config loads causing a bit of an annoyance
    app.finalize_wamp_setup(
        realm=config.flask.wamp.realm,
        cookie_name=config.flask.wamp.cookie_name,
    )

    # Register any app we've created as well
    if izaber_flask:
        app.register_blueprint(izaber_flask, url_prefix=r'/')
Ejemplo n.º 5
0
def load_config(**kwargs):
    request_initialize('config', **kwargs)
    request_initialize('logging', **kwargs)
    config.config_amend_(CONFIG_BASE)

    app.secret_key = config.flask.secret_key
def load_config(**kwargs):
    request_initialize('wamp',**kwargs)
    config.config_amend_(CONFIG_BASE)
    zerp.configure(wamp,config.wamp.zerp.database)
Ejemplo n.º 7
0
def initialize(**kwargs):
    request_initialize('config', **kwargs)
Ejemplo n.º 8
0
def load_config(**options):
    request_initialize('config', **options)
    email_config = config.email.dict()
    mailer.load_config(**email_config)
Ejemplo n.º 9
0
def load_config(**kwargs):
    request_initialize('config', **kwargs)
    request_initialize('logging', **kwargs)
    config.config_amend_(CONFIG_BASE)
Ejemplo n.º 10
0
def initialize(**kwargs):

    request_initialize('config', **kwargs)

    # Setup the paths
    # Path configuration should be in the format:
    # paths: {
    #     path: path to main data directory
    #
    #     custom_path1: encoded path
    #     ...
    #     custom_pathN: encoded path
    #
    # }

    # Setup the paths first
    paths_config = config.get('paths', {})
    paths_config.update(kwargs.get('paths', {}))
    if 'path' not in paths_config:
        for path_location in ['/tmp', '/temp', '.']:
            if os.path.isdir(path_location):
                paths_config.setdefault('path', path_location)
                break
    paths.initialize(**paths_config)

    # Setup the logger
    # Log configuration should be in the format:
    # log: {
    #     filename: paths compatible filepath
    #     filemode: usually 'a'
    #     fileencoding: usually 'utf8'
    #     format: logs formatter compatible format
    #     dateformat: how to display dates
    #     level: filter out everything above this level
    #
    #     custom_logger_name1: {
    #         filename: paths compatible filepath
    #         filemode: usually 'a'
    #         fileencoding: usually 'utf8'
    #         format: logs formatter compatible format
    #         dateformat: how to display dates
    #         level: filter out everything above this level
    #     },
    #     ...
    #     custom_logger_nameN: {
    #         filename: paths compatible filepath
    #         filemode: usually 'a'
    #         fileencoding: usually 'utf8'
    #         format: logs formatter compatible format
    #         dateformat: how to display dates
    #         level: filter out everything above this level
    #     },
    # }
    #
    log_config = dict(logger_defaults)
    log_config.update(config.get('log', {}))
    log_config.update(kwargs.get('log', {}))

    # Default to app_dir/izaber.log if path not defined
    filename = paths.file_get('izaber.log')
    log_config.setdefault('filename', unicode(filename))
    log_config['filename'] = paths.full_fpath(log_config['filename'])

    logging.basicConfig(**log_config)
    logging.getLogger().addHandler(logging.StreamHandler())