How to use the sigal.settings.Status function in sigal

To help you get started, we’ve selected a few sigal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saimn / sigal / tests / test_video.py View on Github external
def test_process_video(tmpdir):
    base, ext = os.path.splitext(TEST_VIDEO)

    settings = create_settings(video_format='ogv', use_orig=True,
                               orig_link=True)
    process_video(SRCFILE, str(tmpdir), settings)
    dstfile = str(tmpdir.join(base + '.ogv'))
    assert os.path.realpath(dstfile) == SRCFILE

    settings = create_settings(video_format='mjpg')
    assert process_video(SRCFILE, str(tmpdir), settings) == Status.FAILURE

    settings = create_settings(thumb_video_delay=-1)
    assert process_video(SRCFILE, str(tmpdir), settings) == Status.FAILURE
github saimn / sigal / tests / test_video.py View on Github external
def test_process_video(tmpdir):
    base, ext = os.path.splitext(TEST_VIDEO)

    settings = create_settings(video_format='ogv', use_orig=True,
                               orig_link=True)
    process_video(SRCFILE, str(tmpdir), settings)
    dstfile = str(tmpdir.join(base + '.ogv'))
    assert os.path.realpath(dstfile) == SRCFILE

    settings = create_settings(video_format='mjpg')
    assert process_video(SRCFILE, str(tmpdir), settings) == Status.FAILURE

    settings = create_settings(thumb_video_delay=-1)
    assert process_video(SRCFILE, str(tmpdir), settings) == Status.FAILURE
github saimn / sigal / tests / test_image.py View on Github external
def test_process_image(tmpdir):
    "Test the process_image function."

    status = process_image('foo.txt', 'none.txt', {})
    assert status == Status.FAILURE

    settings = create_settings(img_processor='ResizeToFill', make_thumbs=False)
    status = process_image(SRCFILE, str(tmpdir), settings)
    assert status == Status.SUCCESS
    im = Image.open(os.path.join(str(tmpdir), TEST_IMAGE))
    assert im.size == settings['img_size']
github saimn / sigal / tests / test_image.py View on Github external
def test_process_image(tmpdir):
    "Test the process_image function."

    status = process_image('foo.txt', 'none.txt', {})
    assert status == Status.FAILURE

    settings = create_settings(img_processor='ResizeToFill', make_thumbs=False)
    status = process_image(SRCFILE, str(tmpdir), settings)
    assert status == Status.SUCCESS
    im = Image.open(os.path.join(str(tmpdir), TEST_IMAGE))
    assert im.size == settings['img_size']
github saimn / sigal / sigal / image.py View on Github external
try:
        generate_image(filepath, outname, settings, options=options)

        if settings['make_thumbs']:
            thumb_name = os.path.join(outpath, get_thumb(settings, filename))
            generate_thumbnail(
                outname, thumb_name, settings['thumb_size'],
                fit=settings['thumb_fit'], options=options,
                thumb_fit_centering=settings["thumb_fit_centering"])
    except Exception as e:
        logger.info('Failed to process: %r', e)
        if logger.getEffectiveLevel() == logging.DEBUG:
            raise
        else:
            return Status.FAILURE

    return Status.SUCCESS
github saimn / sigal / sigal / image.py View on Github external
generate_image(filepath, outname, settings, options=options)

        if settings['make_thumbs']:
            thumb_name = os.path.join(outpath, get_thumb(settings, filename))
            generate_thumbnail(
                outname, thumb_name, settings['thumb_size'],
                fit=settings['thumb_fit'], options=options,
                thumb_fit_centering=settings["thumb_fit_centering"])
    except Exception as e:
        logger.info('Failed to process: %r', e)
        if logger.getEffectiveLevel() == logging.DEBUG:
            raise
        else:
            return Status.FAILURE

    return Status.SUCCESS
github saimn / sigal / sigal / video.py View on Github external
valid_formats = ['mp4', 'webm']
            video_format = settings['video_format']

            if video_format not in valid_formats:
                logger.error('Invalid video_format. Please choose one of: %s',
                             valid_formats)
                raise ValueError

            outname = os.path.join(outpath, basename + '.' + video_format)
            generate_video(filepath, outname, settings,
                           options=settings.get(video_format + '_options'))
    except Exception:
        if logger.getEffectiveLevel() == logging.DEBUG:
            raise
        else:
            return Status.FAILURE

    if settings['make_thumbs']:
        thumb_name = os.path.join(outpath, get_thumb(settings, filename))
        try:
            generate_thumbnail(
                outname, thumb_name, settings['thumb_size'],
                settings['thumb_video_delay'], fit=settings['thumb_fit'],
                options=settings['jpg_options'],
                converter=settings['video_converter'])
        except Exception:
            if logger.getEffectiveLevel() == logging.DEBUG:
                raise
            else:
                return Status.FAILURE

    return Status.SUCCESS
github saimn / sigal / sigal / video.py View on Github external
else:
            return Status.FAILURE

    if settings['make_thumbs']:
        thumb_name = os.path.join(outpath, get_thumb(settings, filename))
        try:
            generate_thumbnail(
                outname, thumb_name, settings['thumb_size'],
                settings['thumb_video_delay'], fit=settings['thumb_fit'],
                options=settings['jpg_options'],
                converter=settings['video_converter'])
        except Exception:
            if logger.getEffectiveLevel() == logging.DEBUG:
                raise
            else:
                return Status.FAILURE

    return Status.SUCCESS