librelist archives

« back to archive

Sigal 0.10.0 crashes on some EXIF data

Sigal 0.10.0 crashes on some EXIF data

From:
Alain Fréhel
Date:
2015-07-09 @ 10:36
Hi,

Thanks for writing Sigal, it's great.

I use Sigal 0.10.0  with Python 3.4 and PIL. It crashes with 
ZeroDivisionError on some pictures because of possibly bogus EXIF values 
in fnumber and focal.

A simple try: except: pass clause around
    simple['fstop'] = float(fnumber[0]) / fnumber[1]
and
    simple['focal'] = round(float(focal[0]) / focal[1])
in sigal/image.py removed the problem.

Regards,

-- 
Alain


Traceback (most recent call last):
   File "/usr/local/bin/sigal", line 9, in <module>
     load_entry_point('sigal==0.10.0-dev', 'console_scripts', 'sigal')()
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 664, in __call__
     return self.main(*args, **kwargs)
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 644, in main
     rv = self.invoke(ctx)
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 991, in invoke
     return _process_result(sub_ctx.command.invoke(sub_ctx))
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 837, in invoke
     return ctx.invoke(self.callback, **ctx.params)
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 464, in invoke
     return callback(*args, **kwargs)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/__init__.py",

line 142, in build
     gal.build(force=force)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",

line 626, in build
     writer.write(album)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/writer.py",

line 110, in write
     page = self.template.render(**self.generate_context(album))
   File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 
969, in render
     return self.environment.handle_exception(exc_info, True)
   File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 
742, in handle_exception
     reraise(exc_type, exc_value, tb)
   File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 36, in 
reraise
     raise value.with_traceback(tb)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",

line 1, in <module>
     {% extends "base.html" %}
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/base.html",

line 41, in <module>
     {% block content %}{% endblock %}
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",

line 59, in <module>
     data-href="{{ media.filename }}" {{ img_description(media) }}>
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",

line 42, in <module>
     {% if media.exif %}
   File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 
397, in getattr
     return getattr(obj, attribute)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/utils.py",

line 134, in __get__
     value = obj.__dict__[self.func.__name__] = self.func(obj)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",

line 159, in exif
     if self.raw_exif and self.ext in ('.jpg', '.jpeg') else None)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/image.py",

line 193, in get_exif_tags
     simple['fstop'] = float(fnumber[0]) / fnumber[1]
ZeroDivisionError: float division by zero


Traceback (most recent call last):
   File "/usr/local/bin/sigal", line 9, in <module>
     load_entry_point('sigal==0.10.0-dev', 'console_scripts', 'sigal')()
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 664, in __call__
     return self.main(*args, **kwargs)
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 644, in main
     rv = self.invoke(ctx)
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 991, in invoke
     return _process_result(sub_ctx.command.invoke(sub_ctx))
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 837, in invoke
     return ctx.invoke(self.callback, **ctx.params)
   File 
"/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py", 
line 464, in invoke
     return callback(*args, **kwargs)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/__init__.py",

line 142, in build
     gal.build(force=force)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",

line 626, in build
     writer.write(album)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/writer.py",

line 110, in write
     page = self.template.render(**self.generate_context(album))
   File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 
969, in render
     return self.environment.handle_exception(exc_info, True)
   File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 
742, in handle_exception
     reraise(exc_type, exc_value, tb)
   File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 36, in 
reraise
     raise value.with_traceback(tb)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",

line 1, in <module>
     {% extends "base.html" %}
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/base.html",

line 41, in <module>
     {% block content %}{% endblock %}
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",

line 59, in <module>
     data-href="{{ media.filename }}" {{ img_description(media) }}>
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",

line 42, in <module>
     {% if media.exif %}
   File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 
397, in getattr
     return getattr(obj, attribute)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/utils.py",

line 134, in __get__
     value = obj.__dict__[self.func.__name__] = self.func(obj)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",

line 159, in exif
     if self.raw_exif and self.ext in ('.jpg', '.jpeg') else None)
   File 

"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/image.py",

line 200, in get_exif_tags
     simple['focal'] = round(float(focal[0]) / focal[1])

Re: [sigal] Sigal 0.10.0 crashes on some EXIF data

From:
Simon
Date:
2015-07-16 @ 22:50
Hi Alain,

Thanks for the report, I have added some checks for these case.

Best,
Simon

Le 09/07/2015 12:36, Alain Fréhel a écrit :
> Hi,
>
> Thanks for writing Sigal, it's great.
>
> I use Sigal 0.10.0  with Python 3.4 and PIL. It crashes with
> ZeroDivisionError on some pictures because of possibly bogus EXIF values
> in fnumber and focal.
>
> A simple try: except: pass clause around
>     simple['fstop'] = float(fnumber[0]) / fnumber[1]
> and
>     simple['focal'] = round(float(focal[0]) / focal[1])
> in sigal/image.py removed the problem.
>
> Regards,
>
> --
> Alain
>
>
> Traceback (most recent call last):
>    File "/usr/local/bin/sigal", line 9, in <module>
>      load_entry_point('sigal==0.10.0-dev', 'console_scripts', 'sigal')()
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 664, in __call__
>      return self.main(*args, **kwargs)
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 644, in main
>      rv = self.invoke(ctx)
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 991, in invoke
>      return _process_result(sub_ctx.command.invoke(sub_ctx))
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 837, in invoke
>      return ctx.invoke(self.callback, **ctx.params)
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 464, in invoke
>      return callback(*args, **kwargs)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/__init__.py",
> line 142, in build
>      gal.build(force=force)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",
> line 626, in build
>      writer.write(album)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/writer.py",
> line 110, in write
>      page = self.template.render(**self.generate_context(album))
>    File "/usr/lib/python3/dist-packages/jinja2/environment.py", line
> 969, in render
>      return self.environment.handle_exception(exc_info, True)
>    File "/usr/lib/python3/dist-packages/jinja2/environment.py", line
> 742, in handle_exception
>      reraise(exc_type, exc_value, tb)
>    File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 36, in
> reraise
>      raise value.with_traceback(tb)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",
> line 1, in <module>
>      {% extends "base.html" %}
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/base.html",
> line 41, in <module>
>      {% block content %}{% endblock %}
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",
> line 59, in <module>
>      data-href="{{ media.filename }}" {{ img_description(media) }}>
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",
> line 42, in <module>
>      {% if media.exif %}
>    File "/usr/lib/python3/dist-packages/jinja2/environment.py", line
> 397, in getattr
>      return getattr(obj, attribute)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/utils.py",
> line 134, in __get__
>      value = obj.__dict__[self.func.__name__] = self.func(obj)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",
> line 159, in exif
>      if self.raw_exif and self.ext in ('.jpg', '.jpeg') else None)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/image.py",
> line 193, in get_exif_tags
>      simple['fstop'] = float(fnumber[0]) / fnumber[1]
> ZeroDivisionError: float division by zero
>
>
> Traceback (most recent call last):
>    File "/usr/local/bin/sigal", line 9, in <module>
>      load_entry_point('sigal==0.10.0-dev', 'console_scripts', 'sigal')()
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 664, in __call__
>      return self.main(*args, **kwargs)
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 644, in main
>      rv = self.invoke(ctx)
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 991, in invoke
>      return _process_result(sub_ctx.command.invoke(sub_ctx))
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 837, in invoke
>      return ctx.invoke(self.callback, **ctx.params)
>    File
> "/usr/local/lib/python3.4/dist-packages/click-4.0-py3.4.egg/click/core.py",
> line 464, in invoke
>      return callback(*args, **kwargs)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/__init__.py",
> line 142, in build
>      gal.build(force=force)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",
> line 626, in build
>      writer.write(album)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/writer.py",
> line 110, in write
>      page = self.template.render(**self.generate_context(album))
>    File "/usr/lib/python3/dist-packages/jinja2/environment.py", line
> 969, in render
>      return self.environment.handle_exception(exc_info, True)
>    File "/usr/lib/python3/dist-packages/jinja2/environment.py", line
> 742, in handle_exception
>      reraise(exc_type, exc_value, tb)
>    File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 36, in
> reraise
>      raise value.with_traceback(tb)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",
> line 1, in <module>
>      {% extends "base.html" %}
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/base.html",
> line 41, in <module>
>      {% block content %}{% endblock %}
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",
> line 59, in <module>
>      data-href="{{ media.filename }}" {{ img_description(media) }}>
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/themes/colorbox/templates/index.html",
> line 42, in <module>
>      {% if media.exif %}
>    File "/usr/lib/python3/dist-packages/jinja2/environment.py", line
> 397, in getattr
>      return getattr(obj, attribute)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/utils.py",
> line 134, in __get__
>      value = obj.__dict__[self.func.__name__] = self.func(obj)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/gallery.py",
> line 159, in exif
>      if self.raw_exif and self.ext in ('.jpg', '.jpeg') else None)
>    File
> 
"/usr/local/lib/python3.4/dist-packages/sigal-0.10.0_dev-py3.4.egg/sigal/image.py",
> line 200, in get_exif_tags
>      simple['focal'] = round(float(focal[0]) / focal[1])