当前位置: 首页>>代码示例>>Python>>正文


Python Config.load方法代码示例

本文整理汇总了Python中thumbor.config.Config.load方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load方法的具体用法?Python Config.load怎么用?Python Config.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thumbor.config.Config的用法示例。


在下文中一共展示了Config.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_app

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
 def get_app(self):
     cfg = Config.load(fixture_for("encrypted_handler_conf.py"))
     importer = Importer(cfg)
     importer.import_modules()
     ctx = Context(None, cfg, importer)
     application = ThumborServiceApp(ctx)
     return application
开发者ID:mikelikespie,项目名称:thumbor,代码行数:9,代码来源:crypto_handler_vows.py

示例2: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):
    """Converts a given url with the specified arguments."""

    parsed_options, arguments = get_options(arguments)

    image_url = arguments[0]
    image_url = quote(image_url)

    try:
        config = Config.load(None)
    except:
        config = None

    if not parsed_options.key and not config:
        sys.stdout.write("Error: The -k or --key argument is mandatory. For more information type thumbor-url -h\n")
        return

    security_key, thumbor_params = get_thumbor_params(image_url, parsed_options, config)

    crypto = CryptoURL(key=security_key)
    url = crypto.generate(**thumbor_params)
    sys.stdout.write("URL:\n")
    sys.stdout.write("%s\n" % url)

    return url
开发者ID:expertise-com,项目名称:thumbor,代码行数:27,代码来源:url_composer.py

示例3: get_config

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def get_config(config_path):
    lookup_paths = [os.curdir,
                    expanduser('~'),
                    '/etc/',
                    dirname(__file__)]

    return Config.load(config_path, conf_name='thumbor.conf', lookup_paths=lookup_paths)
开发者ID:beenanner,项目名称:thumbor,代码行数:9,代码来源:server.py

示例4: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):
    """Runs thumbor server with the specified arguments."""

    server_parameters = get_server_parameters(arguments)
    logging.basicConfig(level=getattr(logging, server_parameters.log_level.upper()))

    lookup_paths = [os.curdir, expanduser("~"), "/etc/", dirname(__file__)]

    config = Config.load(server_parameters.config_path, conf_name="thumbor.conf", lookup_paths=lookup_paths)
    importer = Importer(config)
    importer.import_modules()

    if server_parameters.security_key is None:
        server_parameters.security_key = config.SECURITY_KEY

    if not isinstance(server_parameters.security_key, basestring):
        raise RuntimeError(
            "No security key was found for this instance of thumbor. Please provide one using the conf file or a security key file."
        )

    context = Context(server=server_parameters, config=config, importer=importer)
    application = ThumborServiceApp(context)

    server = HTTPServer(application)
    server.bind(context.server.port, context.server.ip)
    server.start(1)

    try:
        logging.debug("thumbor running at %s:%d" % (context.server.ip, context.server.port))
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        print
        print "-- thumbor closed by user interruption --"
开发者ID:brunomvsouza,项目名称:thumbor,代码行数:35,代码来源:server.py

示例5: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):
    """Runs thumbor server with the specified arguments."""

    server_parameters = get_server_parameters(arguments)

    lookup_paths = [os.curdir, expanduser("~"), "/etc/", dirname(__file__)]

    config = Config.load(
        server_parameters.config_path,
        conf_name="thumbor.conf",
        lookup_paths=lookup_paths,
    )

    logging.basicConfig(
        level=getattr(logging, server_parameters.log_level.upper()),
        format=config.THUMBOR_LOG_FORMAT,
        datefmt=config.THUMBOR_LOG_DATE_FORMAT,
    )

    importer = Importer(config)
    importer.import_modules()

    if importer.error_handler_class is not None:
        importer.error_handler = importer.error_handler_class(config)

    if server_parameters.security_key is None:
        server_parameters.security_key = config.SECURITY_KEY

    if not isinstance(server_parameters.security_key, basestring):
        raise RuntimeError(
            "No security key was found for this instance of thumbor. "
            + "Please provide one using the conf file or a security key file."
        )

    context = Context(server=server_parameters, config=config, importer=importer)

    application = importer.import_class(server_parameters.app_class)(context)

    server = HTTPServer(application)

    if context.server.fd is not None:
        fd_number = get_as_integer(context.server.fd)
        if fd_number is None:
            with open(context.server.fd, "r") as sock:
                fd_number = sock.fileno()

        sock = socket.fromfd(fd_number, socket.AF_UNIX, socket.SOCK_STREAM)
        server.add_socket(sock)
    else:
        server.bind(context.server.port, context.server.ip)

    server.start(1)

    try:
        logging.debug(
            "thumbor running at %s:%d" % (context.server.ip, context.server.port)
        )
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        print("-- thumbor closed by user interruption --")
开发者ID:mrluanma,项目名称:thumbor-heroku,代码行数:62,代码来源:server.py

示例6: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):
    '''Runs thumbor server with the specified arguments.'''

    server_parameters = get_server_parameters(arguments)
    logging.basicConfig(level=getattr(logging, server_parameters.log_level.upper()))
    config = Config.load(server_parameters.config_path)
    importer = Importer(config)
    importer.import_modules()

    if server_parameters.security_key is not None:
        config.SECURITY_KEY = server_parameters.security_key

    if not isinstance(config.SECURITY_KEY, basestring):
        raise RuntimeError('No security key was found for this instance of thumbor. Please provide one using the conf file or a security key file.')

    context = Context(server=server_parameters, config=config, importer=importer)
    application = ThumborServiceApp(context)

    server = HTTPServer(application)
    server.bind(context.server.port, context.server.ip)
    server.start(1)

    try:
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        print
        print "-- thumbor closed by user interruption --"
开发者ID:mikelikespie,项目名称:thumbor,代码行数:29,代码来源:server.py

示例7: get_app

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
 def get_app(self):
     cfg = Config.load(fixture_for('encrypted_handler_conf.py'))
     server_params = ServerParameters(None, None, None, None, None, None)
     server_params.security_key = 'HandlerVows'
     importer = Importer(cfg)
     importer.import_modules()
     ctx = Context(server_params, cfg, importer)
     application = ThumborServiceApp(ctx)
     return application
开发者ID:MechanisM,项目名称:thumbor,代码行数:11,代码来源:crypto_handler_vows.py

示例8: get_config

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def get_config(config_path, use_environment=False):
    if use_environment:
        Config.allow_environment_variables()

    lookup_paths = [os.curdir,
                    expanduser('~'),
                    '/etc/',
                    dirname(__file__)]

    return Config.load(config_path, conf_name='thumbor.conf', lookup_paths=lookup_paths)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:12,代码来源:server.py

示例9: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):
    '''Runs thumbor server with the specified arguments.'''

    server_parameters = get_server_parameters(arguments)

    lookup_paths = [os.curdir,
                    expanduser('~'),
                    '/etc/',
                    dirname(__file__)]

    config = Config.load(server_parameters.config_path, conf_name='thumbor.conf', lookup_paths=lookup_paths)

    logging.basicConfig(
        level=getattr(logging, server_parameters.log_level.upper()),
        format=config.THUMBOR_LOG_FORMAT,
        datefmt=config.THUMBOR_LOG_DATE_FORMAT
    )

    importer = Importer(config)
    importer.import_modules()

    if importer.error_handler_class is not None:
        importer.error_handler = importer.error_handler_class(config)

    if server_parameters.security_key is None:
        server_parameters.security_key = config.SECURITY_KEY

    if not isinstance(server_parameters.security_key, basestring):
        raise RuntimeError(
            'No security key was found for this instance of thumbor. ' +
            'Please provide one using the conf file or a security key file.')

    context = Context(server=server_parameters, config=config, importer=importer)

    application = importer.import_class(server_parameters.app_class)(context)

    server = HTTPServer(application)

    if context.server.fd is not None:
        sock = socket.fromfd(context.server.fd,
                             socket.AF_INET | socket.AF_INET6,
                             socket.SOCK_STREAM)
        server.add_socket(sock)
    else:
        server.bind(context.server.port, context.server.ip)

    server.start(1)

    try:
        logging.debug('thumbor running at %s:%d' % (context.server.ip, context.server.port))
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        print
        print "-- thumbor closed by user interruption --"
开发者ID:HyperionGG,项目名称:thumbor,代码行数:56,代码来源:server.py

示例10: get_app

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def get_app(prevent_result_storage=False, detection_error=False):
    cfg = Config.load(fixture_for('max_age_conf.py'))
    server_params = ServerParameters(None, None, None, None, None, None)

    cfg.DETECTORS = []
    if prevent_result_storage:
        cfg.DETECTORS.append('fixtures.prevent_result_storage_detector')
    if detection_error:
        cfg.DETECTORS.append('fixtures.detection_error_detector')

    importer = Importer(cfg)
    importer.import_modules()
    ctx = Context(server_params, cfg, importer)
    application = ThumborServiceApp(ctx)

    return application
开发者ID:APSL,项目名称:thumbor,代码行数:18,代码来源:max_age_vows.py

示例11: regex

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
    def regex(cls, has_unsafe_or_hash=True, context=None):
        reg = ['/?']

        if has_unsafe_or_hash:
            if context:
                config = context.config
            else:
                config = Config.load(None)
            reg.append(cls.unsafe_or_hash%config.UNSAFE_URL_KEYWORD)
        reg.append(cls.debug)
        reg.append(cls.meta)
        reg.append(cls.trim)
        reg.append(cls.crop)
        reg.append(cls.fit_in)
        reg.append(cls.dimensions)
        reg.append(cls.halign)
        reg.append(cls.valign)
        reg.append(cls.smart)
        reg.append(cls.filters)
        reg.append(cls.image)

        return ''.join(reg)
开发者ID:VladimirFilonov,项目名称:thumbor,代码行数:24,代码来源:url.py

示例12: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main():
    server_parameters = get_server_parameters()
    logging.basicConfig(level=getattr(logging, server_parameters.log_level.upper()))
    config = Config.load(server_parameters.config_path)

    importer = Importer(config)
    importer.import_modules()

    context = Context(server=server_parameters,
                      config=config,
                      importer=importer)

    handlers = [
            (r'/(?P<url>.+)', DumpHandler, { 'context': context })
    ]

    application = tornado.web.Application(handlers)

    server = HTTPServer(application)
    server.bind(context.server.port, context.server.ip)
    server.start(1)

    tornado.ioloop.IOLoop.instance().start()
开发者ID:mikelikespie,项目名称:thumbor-dumper,代码行数:25,代码来源:server.py

示例13: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):  # NOQA
    '''Runs thumbor server with the specified arguments.'''

    server_parameters = get_server_parameters(arguments)

    lookup_paths = [os.curdir,
                    expanduser('~'),
                    '/etc/',
                    dirname(__file__)]

    config = Config.load(server_parameters.config_path, conf_name='thumbor.conf', lookup_paths=lookup_paths)

    if (config.THUMBOR_LOG_CONFIG and config.THUMBOR_LOG_CONFIG != ''):
        logging.config.dictConfig(config.THUMBOR_LOG_CONFIG)
    else:
        logging.basicConfig(
            level=getattr(logging, server_parameters.log_level.upper()),
            format=config.THUMBOR_LOG_FORMAT,
            datefmt=config.THUMBOR_LOG_DATE_FORMAT
        )

    importer = Importer(config)
    importer.import_modules()

    if importer.error_handler_class is not None:
        importer.error_handler = importer.error_handler_class(config)

    if server_parameters.security_key is None:
        server_parameters.security_key = config.SECURITY_KEY

    if not isinstance(server_parameters.security_key, basestring):
        raise RuntimeError(
            'No security key was found for this instance of thumbor. ' +
            'Please provide one using the conf file or a security key file.')

    if config.USE_GIFSICLE_ENGINE:
        server_parameters.gifsicle_path = which('gifsicle')
        if server_parameters.gifsicle_path is None:
            raise RuntimeError(
                'If using USE_GIFSICLE_ENGINE configuration to True, the `gifsicle` binary must be in the PATH '
                'and must be an executable.'
            )

    context = Context(
        server=server_parameters,
        config=config,
        importer=importer
    )

    application = importer.import_class(server_parameters.app_class)(context)

    server = HTTPServer(application)

    if context.server.fd is not None:
        fd_number = get_as_integer(context.server.fd)
        if fd_number is None:
            with open(context.server.fd, 'r') as sock:
                fd_number = sock.fileno()

        sock = socket.fromfd(fd_number,
                             socket.AF_INET | socket.AF_INET6,
                             socket.SOCK_STREAM)
        server.add_socket(sock)
    else:
        server.bind(context.server.port, context.server.ip)

    server.start(1)

    try:
        logging.debug('thumbor running at %s:%d' % (context.server.ip, context.server.port))
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        print
        print "-- thumbor closed by user interruption --"
    finally:
        context.thread_pool.cleanup()
开发者ID:riseofthetigers,项目名称:thumbor,代码行数:78,代码来源:server.py

示例14: get_config

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
 def get_config(self):
     return Config.load(self.get_fixture_path('max_age_conf.py'))
开发者ID:GDxU,项目名称:thumbor,代码行数:4,代码来源:test_max_age.py

示例15: main

# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import load [as 别名]
def main(arguments=None):
    '''Converts a given url with the specified arguments.'''
    if arguments is None:
        arguments = sys.argv[1:]

    parser = optparse.OptionParser(usage='thumbor-url [options] imageurl or type thumbor-url -h (--help) for help', description=__doc__, version=__version__)

    parser.add_option('-k', '--key', dest='key', default=None, help = 'The security key to encrypt the url with [default: %default].' )
    parser.add_option('-w', '--width', dest='width', type='int', default=0, help = 'The target width for the image [default: %default].' )
    parser.add_option('-e', '--height', dest='height', type='int', default=0, help = 'The target height for the image [default: %default].' )
    parser.add_option('-n', '--fitin', dest='fitin', action='store_true', default=False, help = 'Indicates that fit-in resizing should be performed.' )
    parser.add_option('-s', '--smart', action='store_true', dest='smart', default=False, help = 'Indicates that smart cropping should be used.' )
    parser.add_option('-f', '--horizontal-flip', action='store_true', dest='horizontal_flip', default=False, help = 'Indicates that the image should be horizontally flipped.' )
    parser.add_option('-v', '--vertical-flip', action='store_true', dest='vertical_flip', default=False, help = 'Indicates that the image should be vertically flipped.')
    parser.add_option('-a', '--halign', dest='halign', default='center', help = 'The horizontal alignment to use for cropping [default: %default].' )
    parser.add_option('-i', '--valign', dest='valign', default='middle', help = 'The vertical alignment to use for cropping [default: %default].' )
    parser.add_option('',   '--filters', dest='filters', default='', help = 'Filters to be applied to the image, e.g. brightness(10) [default: %default].' )

    parser.add_option('-c', '--crop', dest='crop', default=None, help = 'The coordinates of the points to manual cropping in the format leftxtop:rightxbottom (100x200:400x500) [default: %default].' )

    (parsed_options, arguments) = parser.parse_args(arguments)

    if not arguments:
        print 'Error: The image argument is mandatory. For more information type thumbor-url -h'
        return

    image_url = arguments[0]
    if image_url.startswith('/'):
        image_url = image_url[1:]

    try:
        config = Config.load(None)
    except:
        config = None

    if config:
        print
        print "USING CONFIGURATION FILE AT %s" % config.config_file
        print

    if not parsed_options.key and not config:
        print 'Error: The -k or --key argument is mandatory. For more information type thumbor-url -h'
        return

    security_key = config.SECURITY_KEY if not parsed_options.key else parsed_options.key

    crypt = Crypto(security_key)

    crop_left = crop_top = crop_right = crop_bottom = 0
    if parsed_options.crop:
        crops = parsed_options.crop.split(':')
        crop_left, crop_top = crops[0].split('x')
        crop_right, crop_bottom = crops[1].split('x')

    opt = crypt.encrypt(parsed_options.width,
                        parsed_options.height,
                        parsed_options.smart,
                        parsed_options.fitin,
                        parsed_options.horizontal_flip,
                        parsed_options.vertical_flip,
                        parsed_options.halign,
                        parsed_options.valign,
                        crop_left,
                        crop_top,
                        crop_right,
                        crop_bottom,
                        parsed_options.filters,
                        image_url)
    url = '/%s/%s' % (opt, image_url)

    print 'Encrypted URL: "%s" (without quotes)' % url
开发者ID:MechanisM,项目名称:thumbor,代码行数:73,代码来源:url_composer.py


注:本文中的thumbor.config.Config.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。