Merge branch 'debug-raise-exceptions'
This commit is contained in:
@@ -159,7 +159,10 @@ def process_image(filepath, outpath, settings):
|
||||
fit=settings['thumb_fit'], options=options)
|
||||
except Exception as e:
|
||||
logger.info('Failed to process: %r', e)
|
||||
return Status.FAILURE
|
||||
if logger.getEffectiveLevel() == logging.DEBUG:
|
||||
raise
|
||||
else:
|
||||
return Status.FAILURE
|
||||
|
||||
return Status.SUCCESS
|
||||
|
||||
|
||||
@@ -133,11 +133,7 @@ def generate_thumbnail(source, outname, box, delay, fit=True, options=None):
|
||||
cmd = ['ffmpeg', '-i', source, '-an', '-r', '1',
|
||||
'-ss', delay, '-vframes', '1', '-y', tmpfile]
|
||||
logger.debug('Create thumbnail for video: %s', ' '.join(cmd))
|
||||
|
||||
try:
|
||||
check_subprocess(cmd, source, outname)
|
||||
except Exception:
|
||||
return
|
||||
check_subprocess(cmd, source, outname)
|
||||
|
||||
# use the generate_thumbnail function from sigal.image
|
||||
image.generate_thumbnail(tmpfile, outname, box, fit, options)
|
||||
@@ -169,7 +165,10 @@ def process_video(filepath, outpath, settings):
|
||||
generate_video(filepath, outname, settings,
|
||||
options=settings.get(video_format + '_options'))
|
||||
except Exception:
|
||||
return Status.FAILURE
|
||||
if logger.getEffectiveLevel() == logging.DEBUG:
|
||||
raise
|
||||
else:
|
||||
return Status.FAILURE
|
||||
|
||||
if settings['make_thumbs']:
|
||||
thumb_name = os.path.join(outpath, get_thumb(settings, filename))
|
||||
@@ -179,6 +178,9 @@ def process_video(filepath, outpath, settings):
|
||||
settings['thumb_video_delay'], fit=settings['thumb_fit'],
|
||||
options=settings['jpg_options'])
|
||||
except Exception:
|
||||
return Status.FAILURE
|
||||
if logger.getEffectiveLevel() == logging.DEBUG:
|
||||
raise
|
||||
else:
|
||||
return Status.FAILURE
|
||||
|
||||
return Status.SUCCESS
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
import locale
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
import datetime
|
||||
|
||||
from os.path import join
|
||||
from sigal.gallery import Album, Media, Image, Video, Gallery
|
||||
from sigal.video import SubprocessException
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
@@ -218,6 +220,8 @@ def test_gallery(settings, tmpdir):
|
||||
"Test the Gallery class."
|
||||
|
||||
settings['destination'] = str(tmpdir)
|
||||
settings['webm_options'] = ['-missing-option', 'foobar']
|
||||
|
||||
gal = Gallery(settings, ncpu=1)
|
||||
gal.build()
|
||||
|
||||
@@ -229,6 +233,11 @@ def test_gallery(settings, tmpdir):
|
||||
|
||||
assert '<title>Sigal test gallery</title>' in html
|
||||
|
||||
logging.getLogger('sigal').setLevel(logging.DEBUG)
|
||||
gal = Gallery(settings, ncpu=1)
|
||||
with pytest.raises(SubprocessException):
|
||||
gal.build()
|
||||
|
||||
|
||||
def test_empty_dirs(settings):
|
||||
gal = Gallery(settings, ncpu=1)
|
||||
|
||||
Reference in New Issue
Block a user