Esempio n. 1
0
    def __init__(self):
        redis_host   = options.get('redis_host','localhost')
        redis_port   = options.get('redis_port','6379')
        redis_db     = options.get('redis_db','')
        redis_passwd = options.get('redis_passwd','')

        redis_server = redis.StrictRedis(
            host     = redis_host,
            port     = redis_port,
            db       = redis_db,
            password = redis_passwd
        )

        self.server = redis_server
    def _default_vary_on(self, func, *args, **kwargs):
        args_names = list(inspect.signature(func).parameters.keys())
        params = kwargs.copy()
        for q, arg_value in enumerate(args):
            try:
                arg_name = args_names[q]
            except IndexError:
                arg_name = 'arg_%d' % q
            if arg_name not in params:
                params[arg_name] = arg_value
        result = []

        base_path = options.get("SQL_ALCHEMY_BASE")

        if base_path:
            from sqlalchemy.inspection import inspect as a_inspect
            Base = import_module(base_path)

            for k, v in sorted(params.items(), key=lambda x: x[0]):
                result.extend([
                    k, ''.join(map(str,
                                   a_inspect(v).identity)) if isinstance(
                                       v, Base) else v
                ])
        else:
            for k, v in sorted(params.items(), key=lambda x: x[0]):
                result.extend([k, v])

        return result
Esempio n. 3
0
 def get(self):
     try:
         options = yaml.safe_load(open(self.settings['profiles'], 'r'))
     except Exception as e:
         app_log.error('Could not read profiles: %s', e)
         options = {}
     ret = {
         'profile_list': [{
             'display_name': opt['display_name'],
             'description': opt['description']
         } for opt in options.get('profile_list', [])]
     }
     self.set_header('content-type', 'application/json')
     self.write(json.dumps(ret))
Esempio n. 4
0
            options._options.pop(optname)
        define(optname, **opt)


def register_opts(opts, group=None):
    """Register multiple option schemas at once."""
    for opt in opts:
        register_opt(opt, group)
    return options


def get_options(opts=None, group=None):
    if opts:
        register_opts(opts, group)
    options = register_opts(common_opts, 'common')
    if options.as_dict().get('extra_opts', ''):
        try:
            extra_opts = __import__(options.extra_opts)
            options = register_opts(extra_opts.config.opts, 'extra')
        except Exception as e:
            print "get config error msg %r" % e
    parse_config_file(options.config, final=False)
    parse_command_line()
    return options


if __name__ == "__main__":
    print get_options().as_dict()
    options = get_options()
    print options.get('sql_connection', None)
Esempio n. 5
0
        optname = opt.pop('name')
        if optname in options._options.keys():
            options._options.pop(optname)
        define(optname, **opt)


def register_opts(opts, group=None):
    """Register multiple option schemas at once."""
    for opt in opts:
        register_opt(opt, group)
    return options

def get_options(opts=None, group=None):
    if opts:
        register_opts(opts, group)
    options = register_opts(common_opts, 'common')
    if options.as_dict().get('extra_opts', ''):
        try:
            extra_opts = __import__(options.extra_opts)
            options = register_opts(extra_opts.config.opts, 'extra')
        except:
            print "get config error"
    parse_config_file(options.config, final=False)
    parse_command_line()
    return options

if __name__ == "__main__":
    print get_options().as_dict()
    options = get_options()
    print options.get('sql_connection', None)
Esempio n. 6
0
File: app.py Progetto: reorx/Docky
def run():
    http_server = tornado.httpserver.HTTPServer(Application())

    http_server.listen(options.get('port') or options.default.port)
    tornado.ioloop.IOLoop.instance().start()