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


Python Importer.import_modules方法代码示例

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


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

示例1: get_context

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
def get_context():
    conf = Config()
    conf.ENGINE = "thumbor.engines.pil"
    imp = Importer(conf)
    imp.import_modules()
    imp.filters = [Filter]
    return Context(None, conf, imp)
开发者ID:expertise-com,项目名称:thumbor,代码行数:9,代码来源:fill_filter_vows.py

示例2: main

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [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

示例3: test_import_item_should_be_proper_item

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
    def test_import_item_should_be_proper_item(self):
        importer = Importer(self.get_config())
        importer.import_modules()
        data = {
            'ENGINE': pil_engine,
            'GIF_ENGINE': gif_engine,
            'LOADER': http_loader,
            'STORAGE': file_storage,
            'UPLOAD_PHOTO_STORAGE': file_storage,
            'RESULT_STORAGE': result_file_storage,
            'DETECTORS': (face_detector,),
            'FILTERS': (rgb_filter,),
        }

        for key, value in data.iteritems():
            prop, default_value = (None, None)
            if hasattr(importer, key.lower()):
                prop, default_value = (getattr(importer, key.lower()), value)

            if prop is tuple:
                for index, item in enumerate(prop):
                    expect(item).not_to_be_null()
                    expect(item).to_equal(default_value[index])
            else:
                expect(prop).not_to_be_null()
                expect(prop).to_equal(default_value)
开发者ID:GDxU,项目名称:thumbor,代码行数:28,代码来源:test_importer.py

示例4: get_app

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [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

示例5: main

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [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: get_app

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
    def get_app(self):
        cfg = Config(SECURITY_KEY='ACME-SEC')
        server_params = ServerParameters(None, None, None, None, None, None)
        server_params.gifsicle_path = which('gifsicle')

        cfg.DETECTORS = [
            'thumbor.detectors.face_detector',
            'thumbor.detectors.profile_detector',
            'thumbor.detectors.glasses_detector',
            'thumbor.detectors.feature_detector',
        ]
        cfg.STORAGE = 'thumbor.storages.no_storage'
        cfg.LOADER = 'thumbor.loaders.file_loader'
        cfg.FILE_LOADER_ROOT_PATH = os.path.join(os.path.dirname(__file__), 'imgs')
        cfg.ENGINE = getattr(self, 'engine', None)
        cfg.USE_GIFSICLE_ENGINE = True
        cfg.FFMPEG_PATH = which('ffmpeg')
        cfg.ENGINE_THREADPOOL_SIZE = 10
        cfg.OPTIMIZERS = [
            'thumbor.optimizers.gifv',
        ]
        if not cfg.ENGINE:
            return None

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

        return application
开发者ID:Bladrak,项目名称:thumbor,代码行数:32,代码来源:__init__.py

示例7: topic

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
 def topic(self):
     conf = Config()
     conf.ENGINE = 'thumbor.engines.pil'
     imp = Importer(conf)
     imp.import_modules()
     imp.filters = [Filter]
     return Context(None, conf, imp)
开发者ID:achellies,项目名称:thumbor,代码行数:9,代码来源:fill_filter_vows.py

示例8: get_app

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
    def get_app(self):
        storage_path = '/tmp/thumbor-engines-test/'
        if exists(storage_path):
            rmtree(storage_path)

        self.timeout_handle = None
        cfg = Config(SECURITY_KEY='ACME-SEC', FILE_STORAGE_ROOT_PATH=storage_path)
        server_params = ServerParameters(None, None, None, None, None, None)

        cfg.DETECTORS = [
            'thumbor.detectors.face_detector',
            'thumbor.detectors.profile_detector',
            'thumbor.detectors.glasses_detector',
            'thumbor.detectors.feature_detector',
        ]

        conf_key = self._testMethodName.split('__')[1]
        conf = CONFS.get(conf_key, None)
        if conf:
            for key, value in conf.items():
                setattr(cfg, key, value)

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

        return application
开发者ID:abhishekgodhani,项目名称:thumbor,代码行数:30,代码来源:engines_test.py

示例9: main

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [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

示例10: get_filter

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
    def get_filter(self, filter_name, params_string="", config_context=None):
        config = Config(
            FILTERS=[filter_name],
            LOADER='thumbor.loaders.file_loader',
            FILE_LOADER_ROOT_PATH=join(dirname(realpath(__file__)), 'fixtures', 'filters')
        )
        importer = Importer(config)
        importer.import_modules()

        req = RequestParameters()

        context = Context(config=config, importer=importer)
        context.request = req
        context.request.engine = context.modules.engine

        if config_context is not None:
            config_context(context)

        self.context = context

        fltr = importer.filters[0]
        fltr.pre_compile()

        context.transformer = Transformer(context)

        return fltr(params_string, context=context)
开发者ID:GDxU,项目名称:thumbor,代码行数:28,代码来源:base.py

示例11: topic

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
            def topic(self, test_item):
                test_data, config = test_item
                importer = Importer(config)
                importer.import_modules()

                if hasattr(importer, test_data[0].lower()):
                    return (getattr(importer, test_data[0].lower()), test_data[1])
                return (None, None)
开发者ID:mikelikespie,项目名称:thumbor,代码行数:10,代码来源:importer_vows.py

示例12: test_can_create_context_with_importer

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
    def test_can_create_context_with_importer(self):
        cfg = Config()
        importer = Importer(cfg)
        importer.import_modules()
        ctx = Context(config=cfg, importer=importer)

        expect(ctx.modules).not_to_be_null()
        expect(ctx.modules.importer).to_equal(importer)
开发者ID:dannyeuu,项目名称:thumbor,代码行数:10,代码来源:test_context.py

示例13: get_importer

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
def get_importer(config):
    importer = Importer(config)
    importer.import_modules()

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

    return importer
开发者ID:beenanner,项目名称:thumbor,代码行数:10,代码来源:server.py

示例14: get_context

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
    def get_context(self):
        cfg = Config()
        cfg.HEALTHCHECK_ROUTE = '/'

        importer = Importer(cfg)
        importer.import_modules()

        return Context(None, cfg, importer)
开发者ID:okor,项目名称:thumbor,代码行数:10,代码来源:test_healthcheck.py

示例15: topic

# 需要导入模块: from thumbor.importer import Importer [as 别名]
# 或者: from thumbor.importer.Importer import import_modules [as 别名]
 def topic(self):
     conf = Config()
     conf.METRICS = 'tc_librato.metrics.librato_metrics'
     conf.LIBRATO_USER = 'test'
     conf.LIBRATO_TOKEN = 'test'
     conf.LIBRATO_NAME_PREFIX = 'test'
     imp = Importer(conf)
     imp.import_modules()
     return Context(None, conf, imp)
开发者ID:thumbor-community,项目名称:librato,代码行数:11,代码来源:metrics_vows.py


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