• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python logger.exception函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: request

 def request(self):
     try:
         self.thumbor_filter.context.modules.loader.load(
             self.thumbor_filter.context, self.url, self.on_fetch_done)
     except Exception as err:
         self.failed = True
         logger.exception(err)
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:7,代码来源:distributed_collage.py


示例2: put_detector_data

 def put_detector_data(self, path, data):
     key = self.detector_key_for(path)
     try:
         self.storage.set(key, dumps(data))
     except:
         logger.exception("[MEMCACHED] failed to set key '{0}'".format(key));
     return key
开发者ID:gi11es,项目名称:thumbor-memcached,代码行数:7,代码来源:storage.py


示例3: detect

    def detect(self, callback):
        engine = self.context.modules.engine
        try:
            img = np.array(
                engine.convert_to_grayscale(
                    update_image=False,
                    with_alpha=False
                )
            )
        except Exception as e:
            logger.exception(e)
            logger.warn('Error during feature detection; skipping to next detector')
            self.next(callback)
            return

        points = cv2.goodFeaturesToTrack(
            img,
            maxCorners=20,
            qualityLevel=0.04,
            minDistance=1.0,
            useHarrisDetector=False,
        )
        if points is not None:
            for point in points:
                x, y = point.ravel()
                self.context.request.focal_points.append(FocalPoint(x.item(), y.item(), 1))
            callback()
        else:
            self.next(callback)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:29,代码来源:__init__.py


示例4: srgb

    def srgb(self):
        try:
            if not isinstance(self.engine, PILEngine):
                logger.warn('Could not perform profileToProfile conversion: engine is not PIL engine')
                return

            if (ImageCms is None):
                logger.warn('ImageCms is not installed. Could not perform profileToProfile conversion')
                return

            image = self.engine.image

            embedded_profile = image.info.get('icc_profile')

            if not embedded_profile:
                logger.debug('Image does not have embedded profile. Assuming already in sRGB')
                return

            embedded_profile = BytesIO(embedded_profile)
            srgb_profile = BytesIO(tiny_srgb)

            output_mode = 'RGBA' if 'A' in image.mode else 'RGB'
            image = ImageCms.profileToProfile(image, embedded_profile, srgb_profile, renderingIntent=0,
                                              outputMode=output_mode)

            self.engine.image = image
            self.engine.icc_profile = image.info.get('icc_profile')
        except Exception as err:
            logger.exception(err)
开发者ID:PopSugar,项目名称:thumbor-plugins,代码行数:29,代码来源:srgb.py


示例5: put

 def put(self, path, contents):
     key = self.key_for(path)
     try:
         self.storage.set(key, contents, time=self.context.config.STORAGE_EXPIRATION_SECONDS)
     except:
         logger.exception("[MEMCACHED] failed to set key '{0}'".format(key));
     return path
开发者ID:gi11es,项目名称:thumbor-memcached,代码行数:7,代码来源:storage.py


示例6: smart_detect

    def smart_detect(self):
        if not (self.context.modules.detectors and self.context.request.smart):
            self.do_image_operations()
            return

        try:
            # Beware! Boolean hell ahead.
            #
            # The `running_smart_detection` flag is needed so we can know
            # whether `after_smart_detect()` is running synchronously or not.
            #
            # If we're running it in a sync fashion it will set
            # `should_run_image_operations` to True so we can avoid running
            # image operation inside the try block.
            self.should_run_image_operations = False
            self.running_smart_detection = True
            self.do_smart_detection()
            self.running_smart_detection = False
        except Exception:
            if not self.context.config.IGNORE_SMART_ERRORS:
                raise

            logger.exception("Ignored error during smart detection")
            if self.context.config.USE_CUSTOM_ERROR_HANDLING:
                self.context.modules.importer.error_handler.handle_error(context=self.context, handler=self.context.request_handler, exception=sys.exc_info())

            self.context.request.prevent_result_storage = True
            self.context.request.detection_error = True
            self.do_image_operations()

        if self.should_run_image_operations:
            self.do_image_operations()
开发者ID:achellies,项目名称:thumbor,代码行数:32,代码来源:transformer.py


示例7: _get_exif_segment

 def _get_exif_segment(self):
     try:
         segment = ExifSegment(None, None, self.exif, 'ro')
     except Exception:
         logger.exception('Ignored error handling exif for reorientation')
     else:
         return segment
     return None
开发者ID:GDxU,项目名称:thumbor,代码行数:8,代码来源:__init__.py


示例8: read

    def read(self, extension=None, quality=None):
        #returns image buffer in byte format.
        img_buffer = BytesIO()

        ext = extension or self.extension

        options = {
            'quality': quality
        }

        if ext == '.jpg' or ext == '.jpeg':
            options['optimize'] = True
            options['progressive'] = True

            if quality is None:
                options['quality'] = 'keep'

        if options['quality'] is None:
            options['quality'] = self.context.config.QUALITY

        if self.icc_profile is not None:
            options['icc_profile'] = self.icc_profile

        if self.context.config.PRESERVE_EXIF_INFO:
            exif = self.image.info.get('exif', None)
            if exif is not None:
                options['exif'] = exif

        if self.image.mode == 'P' and self.transparency:
            options['transparency'] = self.transparency

        try:
            if ext == '.webp':
                if self.image.mode not in ['RGB', 'RGBA']:
                    mode = None
                    if self.image.mode != 'P':
                        mode = 'RGBA' if self.image.mode[-1] == 'A' else 'RGB'
                    self.image = self.image.convert(mode)

            self.image.save(img_buffer, FORMATS[ext], **options)
        except IOError:
            logger.exception('Could not save as improved image, consider to increase ImageFile.MAXBLOCK')
            self.image.save(img_buffer, FORMATS[ext])
        except KeyError:
            logger.exception('Image format not found in PIL: %s' % ext)

            #extension is not present or could not help determine format => force JPEG
            if self.image.mode in ['P', 'RGBA', 'LA']:
                self.image.format = FORMATS['.png']
                self.image.save(img_buffer, FORMATS['.png'])
            else:
                self.image.format = FORMATS['.jpg']
                self.image.save(img_buffer, FORMATS['.jpg'])

        results = img_buffer.getvalue()
        img_buffer.close()
        return results
开发者ID:cazacugmihai,项目名称:thumbor,代码行数:57,代码来源:pil.py


示例9: _load_results

    def _load_results(self, context):
        try:
            results, content_type = BaseHandler._load_results(self, context)
        except Exception:
            logger.exception('[ImagesHandler] Exception during _load_results', extra=log_extra(context))
            self._error(500)
            return None, None

        return results, content_type
开发者ID:wikimedia,项目名称:operations-debs-python-thumbor-wikimedia,代码行数:9,代码来源:images.py


示例10: _execute_in_foreground

 def _execute_in_foreground(self, operation, callback):
     result = Future()
     returned = None
     try:
         returned = operation()
     except Exception as e:
         # just log exception and release ioloop
         returned = e
         logger.exception(e)
     result.set_result(returned)
     callback(result)
开发者ID:Bladrak,项目名称:thumbor,代码行数:11,代码来源:context.py


示例11: _get_exif_segment

    def _get_exif_segment(self):
        if (not hasattr(self, 'exif')) or self.exif is None:
            return None

        try:
            segment = ExifSegment(None, None, self.exif, 'ro')
        except Exception:
            logger.exception('Ignored error handling exif for reorientation')
        else:
            return segment
        return None
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:11,代码来源:__init__.py


示例12: _execute_in_foreground

    def _execute_in_foreground(self, operation, callback):
        result = Future()

        try:
            returned = operation()
        except Exception as e:
            logger.exception('[ThreadPool] %s', e)
            result.set_exception(e)
        else:
            result.set_result(returned)

        callback(result)
开发者ID:dannyeuu,项目名称:thumbor,代码行数:12,代码来源:context.py


示例13: put_crypto

    def put_crypto(self, path):
        if not self.context.config.STORES_CRYPTO_KEY_FOR_EACH_IMAGE:
            return

        if not self.context.server.security_key:
            raise RuntimeError("STORES_CRYPTO_KEY_FOR_EACH_IMAGE can't be True if no SECURITY_KEY specified")

        key = self.crypto_key_for(path)
        try:
            self.storage.set(key, self.context.server.security_key)
        except:
            logger.exception("[MEMCACHED] failed to set key '{0}'".format(key));
        return key
开发者ID:gi11es,项目名称:thumbor-memcached,代码行数:13,代码来源:storage.py


示例14: inner

        def inner(future):
            try:
                future_result = future.result()
            except Exception as e:
                logger.exception('[BaseHander.finish_request] %s', e)
                self._error(500, 'Error while trying to fetch the image: {}'.format(e))
                return

            results, content_type = future_result
            self._write_results_to_client(results, content_type)

            if should_store:
                tornado.ioloop.IOLoop.instance().add_callback(self._store_results, result_storage, metrics, results)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:13,代码来源:__init__.py


示例15: icc_profile_apply

    def icc_profile_apply(self, profile=None):
        # Check whether input image has color management.
        if not self.engine.icc_profile:
            logger.info('ICC: Image has no embedded profile. Skipping this image.')
            return

        # Sanitize profile parameter.
        if profile != None:
            profile = os.path.basename(profile).lstrip('.')
            if len(profile) == 0:
                logger.warning('ICC: Invalid profile name.')
                return

        # Find output profile.
        outprofile = self._find_profile(profile)
        if not outprofile:
            logger.warning('ICC: Failed to load profile: {:s}'.format(profile))
            return

        try:
            ext = self.engine.extension
            fmt = Image.EXTENSION[ext.lower()]
        except:
            logger.exception('ICC: Failed to determine image format and extension before attempting to apply profile: {:s}'.format(profile))
            return

        try:
            inmode = self.engine.get_image_mode()
            insize = self.engine.size
            inimg = Image.frombytes(inmode, insize, self.engine.get_image_data())

            # In PIL>=3.0.0 / Thumbor 6, icc_profile is sometimes a tuple :/
            # https://github.com/python-pillow/Pillow/issues/1462
            profile_data = self.engine.icc_profile
            if type(profile_data) == tuple:
                profile_data = profile_data[0]
            inprofile = StringIO(profile_data)

            outmode = 'RGBA' if 'A' in inmode else 'RGB'
        except:
            logger.exception('ICC: Failed to determine image properties before attempting to apply profile: {:s}'.format(profile))
            return

        logger.info('ICC: Attempting to apply profile: {:s}, inmode: {:s}, outmode: {:s}'.format(profile, inmode, outmode))
        try:
            outimg = ImageCms.profileToProfile(inimg, inprofile, outprofile, outputMode=outmode)
        except:
            logger.exception('ICC: Failed to apply profile: {:s}, inmode: {:s}, outmode: {:s}'.format(profile, inmode, outmode))
            return

        # Reload the image into the engine.
        outbuf = StringIO()
        try:
            outimg.save(outbuf, fmt)
            self.engine.load(outbuf.getvalue(), ext)
        except:
            logger.exception('ICC: Failed load the image with an applied profile: {:s}, inmode: {:s}, outmode: {:s}'.format(profile, inmode, outmode))
            return
        finally:
            outbuf.close()
开发者ID:znerol,项目名称:thumbor-icc,代码行数:60,代码来源:icc_profile_apply.py


示例16: read

    def read(self, extension=None, quality=None):
        if quality is None:
            quality = self.context.request.quality
        #returns image buffer in byte format.
        img_buffer = BytesIO()

        ext = extension or self.extension
        options = {
            'quality': quality
        }
        if ext == '.jpg' or ext == '.jpeg':
            options['optimize'] = True
            options['progressive'] = True

        if self.icc_profile is not None:
            options['icc_profile'] = self.icc_profile

        if self.context.config.PRESERVE_EXIF_INFO:
            exif = self.image.info.get('exif', None)
            if exif is not None:
                options['exif'] = exif

        image_format = self.context.request.format
        if image_format is None:
            image_format = FORMATS[ext]
        image_format = str(image_format).upper()

        try:
            if image_format == 'WEBP' and self.image.mode in ['L', 'LA', 'P', 'RGBA']:
                self.image = self.image.convert('RGB')

            self.image.save(img_buffer, image_format, **options)
        except IOError:
            logger.exception('Could not save as improved image, consider to increase ImageFile.MAXBLOCK')
            self.image.save(img_buffer, FORMATS[ext])
        except KeyError:
            logger.exception('Image format not found in PIL: %s' % image_format)
            #extension is not present or could not help determine format => force JPEG
            #TODO : guess format by image headers maybe
            if self.image.mode in ['P', 'RGBA', 'LA']:
                self.image.format = FORMATS['.png']
                self.image.save(img_buffer, FORMATS['.png'])
            else:
                self.image.format = FORMATS['.jpg']
                self.image.save(img_buffer, FORMATS['.jpg'])

        results = img_buffer.getvalue()
        img_buffer.close()
        return results
开发者ID:Hazer,项目名称:thumbor,代码行数:49,代码来源:pil.py


示例17: inner

        def inner(future):
            try:
                future_result = future.result()
            except Exception as e:
                logger.exception('[BaseHander.finish_request] %s', e)
                self._error(500, 'Error while trying to fetch the image: {}'.format(e))
                return

            results, content_type = future_result
            self._write_results_to_client(context, results, content_type)

            if should_store:
                self._store_results(context, results)

            schedule.run_pending()
开发者ID:scorphus,项目名称:thumbor,代码行数:15,代码来源:__init__.py


示例18: process

 def process(self, canvas_width, canvas_height, size):
     try:
         self.engine.load(self.buffer, self.extension)
         width, height = self.engine.size
         new_width, new_height = calc_new_size_by_height(width, height, canvas_height)
         focal_points = StandaloneFaceDetector.features_to_focal_points(
             StandaloneFaceDetector.get_features(self.thumbor_filter.context, self.engine))
         if focal_points:
             self.resize_focal_points(focal_points, float(new_width) / width)
         else:
             focal_points.append(FocalPoint.from_alignment('center', 'top', new_width, new_height))
         self.engine.resize(new_width, new_height)
         self.engine.focus(focal_points)
         StandaloneFaceDetector.auto_crop(self.engine, focal_points, size, canvas_height)
     except Exception as err:
         logger.exception(err)
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:16,代码来源:distributed_collage.py


示例19: save_on_disc

    def save_on_disc(self):
        if self.fetched:
            try:
                self.engine.load(self.buffer, self.extension)
            except Exception as err:
                self.failed = True
                logger.exception(err)

            try:
                self.thumbor_filter.storage.put(self.url, self.engine.read())
                self.thumbor_filter.storage.put_crypto(self.url)
            except Exception as err:
                self.failed = True
                logger.exception(err)
        else:
            self.failed = True
            logger.error("filters.distributed_collage: Can't save unfetched image")
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:17,代码来源:distributed_collage.py


示例20: detect

    def detect(self, callback):
        self.context.request.prevent_result_storage = True
        try:
            if not Detector.detect_task:
                celery_tasks = CeleryTasks(
                    self.context.config.SQS_QUEUE_KEY_ID,
                    self.context.config.SQS_QUEUE_KEY_SECRET,
                    self.context.config.SQS_QUEUE_REGION, None
                )
                Detector.detect_task = celery_tasks.get_detect_task()

            Detector.detect_task.delay('all', self.context.request.image_url, self.context.request.image_url)
        except RuntimeError:
            self.context.request.detection_error = True
            Detector.detect_task = None
            logger.exception('Celery Error')
        finally:
            callback([])
开发者ID:Bladrak,项目名称:thumbor,代码行数:18,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger.warn函数代码示例发布时间:2022-05-27
下一篇:
Python logger.error函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap