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


Python logger.error函数代码示例

本文整理汇总了Python中thumbor.utils.logger.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: command

    def command(
        cls,
        context,
        pre=[],
        post=[],
        buffer='',
        input_temp_file=None
    ):
        if not input_temp_file:
            input_temp_file = NamedTemporaryFile()
            input_temp_file.write(buffer)
            input_temp_file.flush()

        command = [context.config.EXIFTOOL_PATH]
        command += pre
        command.append(input_temp_file.name)
        command += post

        logger.debug('[ExiftoolRunner] command: %r' % command, extra=log_extra(context))

        code, stderr, stdout = ShellRunner.command(command, context)

        input_temp_file.close()

        if stderr:
            logger.error('[ExiftoolRunner] error: %r' % stderr, extra=log_extra(context))

        return stdout
开发者ID:wikimedia,项目名称:operations-debs-python-thumbor-wikimedia,代码行数:28,代码来源:__init__.py

示例2: dispatch

    def dispatch(self, file_key):
        """ Callback method for getObject from s3 """
        if not file_key or 'Error' in file_key or 'Body' not in file_key:

            logger.error(
                "ERROR retrieving image from S3 {0}: {1}".
                format(self.key, str(file_key)))

            # If we got here, there was a failure.
            # We will return 404 if S3 returned a 404, otherwise 502.
            result = LoaderResult()
            result.successful = False

            if not file_key:
                result.error = LoaderResult.ERROR_UPSTREAM
                self.callback(result)
                return

            response_metadata = file_key.get('ResponseMetadata', {})
            status_code = response_metadata.get('HTTPStatusCode')

            if status_code == 404:
                result.error = LoaderResult.ERROR_NOT_FOUND
                self.callback(result)
                return

            if self.retries_counter < self.max_retry:
                self.__increment_retry_counter()
                self.bucket_loader.get(self.key,
                                       callback=self.dispatch)
            else:
                result.error = LoaderResult.ERROR_UPSTREAM
                self.callback(result)
        else:
            self.callback(file_key['Body'].read())
开发者ID:thumbor-community,项目名称:aws,代码行数:35,代码来源:s3_loader.py

示例3: load

    def load(self, buffer, extension):
        self.extension = extension

        if extension is None:
            mime = self.get_mimetype(buffer)
            self.extension = EXTENSION.get(mime, '.jpg')

        if self.extension == '.svg':
            buffer = self.convert_svg_to_png(buffer)

        image_or_frames = self.create_image(buffer)

        if METADATA_AVAILABLE:
            try:
                self.metadata = ImageMetadata.from_buffer(buffer)
                self.metadata.read()
            except Exception as e:
                logger.error('Error reading image metadata: %s' % e)

        if self.context.config.ALLOW_ANIMATED_GIFS and isinstance(
                image_or_frames, (list, tuple)):
            self.image = image_or_frames[0]
            if len(image_or_frames) > 1:
                self.multiple_engine = MultipleEngine(self)
                for frame in image_or_frames:
                    self.multiple_engine.add_frame(frame)
                self.wrap(self.multiple_engine)
        else:
            self.image = image_or_frames

        if self.source_width is None:
            self.source_width = self.size[0]
        if self.source_height is None:
            self.source_height = self.size[1]
开发者ID:kagel,项目名称:thumbor,代码行数:34,代码来源:__init__.py

示例4: distributed_collage

    def distributed_collage(self, callback, orientation, alignment, urls):
        logger.debug('filters.distributed_collage: distributed_collage invoked')
        self.storage = self.context.modules.storage

        self.callback = callback
        self.orientation = orientation
        self.alignment = alignment
        self.urls = urls.split('|')
        self.images = {}

        total = len(self.urls)
        if total > self.MAX_IMAGES:
            logger.error('filters.distributed_collage: Too many images to join')
            callback()
        elif total == 0:
            logger.error('filters.distributed_collage: No images to join')
            callback()
        else:
            self.urls = self.urls[:self.MAX_IMAGES]
            for url in self.urls:
                self.images[url] = Picture(url, self)

            # second loop needed to ensure that all images are in self.images
            # otherwise, self.on_image_fetch can call the self.assembly()
            # without that all images had being loaded
            for url in self.urls:
                buffer = yield tornado.gen.maybe_future(self.storage.get(url))
                pic = self.images[url]
                if buffer is not None:
                    pic.fill_buffer(buffer)
                    self.on_image_fetch()
                else:
                    pic.request()
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:33,代码来源:distributed_collage.py

示例5: post

    def post(self, **kwargs):
        self.should_return_image = False

        # URL can be passed as a URL argument or in the body
        url = kwargs['url'] if 'url' in kwargs else kwargs['key']

        if not url:
            logger.error("Couldn't find url param in body or key in URL...")
            raise tornado.web.HTTPError(404)

        options = RequestParser.path_to_parameters(url)

        yield self.check_image(options)

        # We check the status code, if != 200 the image is incorrect, and we shouldn't store the key
        if self.get_status() == 200:
            logger.debug("Image is checked, clearing the response before trying to store...")
            self.clear()
            try:
                shortener = Shortener(self.context)
                key = shortener.generate(url)
                shortener.put(key, url)

                self.write(json.dumps({'key': key}))
                self.set_header("Content-Type", "application/json")
            except Exception as e:
                logger.error("An error occurred while trying to store shortened URL: {error}.".format(error=e.message))
                self.set_status(500)
                self.write(json.dumps({'error': e.message}))
开发者ID:gi11es,项目名称:shortener,代码行数:29,代码来源:shortener.py

示例6: get_image

    def get_image(self):
        try:
            result = yield self._fetch(self.context.request.image_url)

            if not result.successful:
                if result.loader_error == LoaderResult.ERROR_NOT_FOUND:
                    self._error(404)
                    return
                elif result.loader_error == LoaderResult.ERROR_UPSTREAM:
                    # Return a Bad Gateway status if the error came from upstream
                    self._error(502)
                    return
                elif result.loader_error == LoaderResult.ERROR_TIMEOUT:
                    # Return a Gateway Timeout status if upstream timed out (i.e. 599)
                    self._error(504)
                    return
                else:
                    self._error(500)
                    return

        except Exception as e:
            msg = "[BaseHandler] get_image failed for url `{url}`. error: `{error}`".format(
                url=self.context.request.image_url, error=e
            )

            self.log_exception(*sys.exc_info())

            if "cannot identify image file" in e.message:
                logger.warning(msg)
                self._error(400)
            else:
                logger.error(msg)
                self._error(500)
            return

        normalized = result.normalized
        buffer = result.buffer
        engine = result.engine

        req = self.context.request

        if engine is None:
            if buffer is None:
                self._error(504)
                return

            engine = self.context.request.engine
            engine.load(buffer, self.context.request.extension)

        def transform():
            self.normalize_crops(normalized, req, engine)

            if req.meta:
                self.context.request.engine = JSONEngine(engine, req.image_url, req.meta_callback)

            after_transform_cb = functools.partial(self.after_transform, self.context)
            Transformer(self.context).transform(after_transform_cb)

        self.filters_runner.apply_filters(thumbor.filters.PHASE_AFTER_LOAD, transform)
开发者ID:nyimbi,项目名称:thumbor,代码行数:59,代码来源:__init__.py

示例7: __init__

    def __init__(self, context):
        super(Optimizer, self).__init__(context)

        self.runnable = True
        self.pngcrush_path = self.context.config.PNGCRUSH_PATH
        if not (os.path.isfile(self.pngcrush_path) and os.access(self.pngcrush_path, os.X_OK)):
            logger.error("ERROR pngcrush path '{0}' is not accessible".format(self.pngcrush_path))
            self.runnable = False
开发者ID:AppSorcery,项目名称:coreo_thumbor,代码行数:8,代码来源:pngcrush.py

示例8: __init__

    def __init__(self, context):
        super(Optimizer, self).__init__(context)

        self.runnable = True
        self.jpegrecompress_path = self.context.config.JPEGRECOMPRESS_PATH

        if not (os.path.isfile(self.jpegrecompress_path) and os.access(self.jpegrecompress_path, os.X_OK)):
            logger.error("ERROR jpeg-recompress path '{0}' is not accessible".format(self.jpegrecompress_path))
            self.runnable = False
开发者ID:PopSugar,项目名称:thumbor-plugins,代码行数:9,代码来源:jpegrecompress.py

示例9: __init__

    def __init__(self, context):
        super(Optimizer, self).__init__(context)

        self.runnable = True
        self.imgmin_path = self.context.config.IMGMIN_PATH

        if not ( os.path.isfile(self.imgmin_path) ):
            logger.error("ERROR path '{0}' is not accessible".format(self.imgmin_path))
            self.runnable = False
开发者ID:PopSugar,项目名称:thumbor-plugins,代码行数:9,代码来源:auto.py

示例10: __init__

    def __init__(self, context):
        super(Optimizer, self).__init__(context)

        self.runnable = True
        self.zopflipng_path = self.context.config.ZOPFLIPNG_PATH

        if not (os.path.isfile(self.zopflipng_path) and os.access(self.zopflipng_path, os.X_OK)):
            logger.error("ERROR zopflipng path '{0}' is not accessible".format(self.zopflipng_path))
            self.runnable = False
开发者ID:PopSugar,项目名称:thumbor-plugins,代码行数:9,代码来源:zopflipng.py

示例11: return_contents

def return_contents(response, url, callback):
    if response.error:
        logger.error("ERROR retrieving image {0}: {1}".format(url, str(response.error)))
        callback(None)
    elif response.body is None or len(response.body) == 0:
        logger.error("ERROR retrieving image {0}: Empty response.".format(url))
        callback(None)
    else:
        callback(response.body)
开发者ID:lmello,项目名称:thumbor,代码行数:9,代码来源:http_loader.py

示例12: __init__

    def __init__(self, context):
        super(Optimizer, self).__init__(context)

        self.runnable = True
        self.mozjpeg_path = self.context.config.MOZJPEG_PATH
        self.mozjpeg_level = self.context.config.MOZJPEG_QUALITY or '75'

        if not (os.path.isfile(self.mozjpeg_path) and os.access(self.mozjpeg_path, os.X_OK)):
            logger.error("ERROR mozjpeg path '{0}' is not accessible".format(self.mozjpeg_path))
            self.runnable = False
开发者ID:Cartrdge,项目名称:thumbor-plugins,代码行数:10,代码来源:mozjpeg.py

示例13: handle_error

    def handle_error(self, context, handler, exception):
        ex_type, value, tb = exception

        ex_msg = traceback.format_exception_only(ex_type, value)
        tb_msg = traceback.format_tb(tb)

        extra = log_extra(context)
        extra['traceback'] = ''.join(tb_msg)

        logger.error(''.join(ex_msg), extra=extra)
开发者ID:wikimedia,项目名称:operations-debs-python-thumbor-wikimedia,代码行数:10,代码来源:logstash.py

示例14: put

 def put(self, bytes):
     normalized_path = self.normalize_path(self.context.request.url)
     uri = self.context.config.get('RESULT_STORAGE_WEBDAV_URI') + normalized_path
     logger.debug("[RESULT_STORAGE] Making PUT request to: %s", uri)
     http_client = HTTPClient()
     try:
         response = http_client.fetch(uri, method='PUT', body=bytes)
         logger.debug("[RESULT_STORAGE] Success on PUT request!")
     except HTTPError as e:
         logger.error("[RESULT_STORAGE] Error on PUT request: %s", e)
开发者ID:clifff,项目名称:thumbor_webdav_result_storage,代码行数:10,代码来源:__init__.py

示例15: validate

    def validate(self, path):
        if not hasattr(self.loader, 'validate'):
            return True

        is_valid = self.loader.validate(path)

        if not is_valid:
            logger.error('Request denied because the specified path "%s" was not identified by the loader as a valid path' % path)

        return is_valid
开发者ID:douglas,项目名称:thumbor,代码行数:10,代码来源:__init__.py


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