def test_generate_in_progress_resizer_option_true( redis_cache, resizetarget_opts, image1_data, image1_name, tmpdir ): config = Config( root=str(tmpdir), url='/', redis_host=redis_cache.redis, raise_on_generate_in_progress=True ) resizer = flask_resize.make_resizer(config) # Save original file resizer.storage_backend.save(image1_name, image1_data) def run(x): return resizer(image1_name) pool = Pool(2) with pytest.raises(flask_resize.exc.GenerateInProgress): pool.map(run, [None] * 2)
def test_generate_in_progress_resizer_option_false(redis_cache, resizetarget_opts, image1_data, image1_name, tmpdir): config = Config(root=str(tmpdir), url='/', raise_on_generate_in_progress=False) resizer = flask_resize.make_resizer(config) # Save original file resizer.storage_backend.save(image1_name, image1_data) def run(x): return resizer(image1_name) pool = Pool(2) data = pool.map(run, [None] * 2) assert len(data) == 2
def test_generate_in_progress_resizer_option_true(redis_cache, resizetarget_opts, image1_data, image1_name, tmpdir): config = Config(root=str(tmpdir), url='/', raise_on_generate_in_progress=True) resizer = flask_resize.make_resizer(config) # Save original file resizer.storage_backend.save(image1_name, image1_data) def run(x): return resizer(image1_name) pool = Pool(2) with pytest.raises(flask_resize.exc.GenerateInProgress): pool.map(run, [None] * 2)
def test_generate_in_progress_resizer_option_false( redis_cache, resizetarget_opts, image1_data, image1_name, tmpdir ): config = Config( root=str(tmpdir), url='/', redis_host=redis_cache.redis, raise_on_generate_in_progress=False ) resizer = flask_resize.make_resizer(config) # Save original file resizer.storage_backend.save(image1_name, image1_data) def run(x): return resizer(image1_name) pool = Pool(2) data = pool.map(run, [None] * 2) assert len(data) == 2
import os import argh import flask_resize config = flask_resize.configuration.Config.from_pyfile( os.environ['FLASK_RESIZE_CONF'] ) resize = flask_resize.make_resizer(config) @argh.named('images') def clear_images(): """Delete all generated images from the storage backend""" for filepath in resize.storage_backend.delete_tree( resize.target_directory ): yield filepath @argh.named('cache') def list_cache(): """List all items found in cache""" for key in resize.cache_store.all(): yield key @argh.named('images') def list_images(): """List all generated images found in storage backend"""
from pathlib import Path import sqlite3 from bs4 import BeautifulSoup import flask_resize resize = flask_resize.make_resizer( flask_resize.configuration.Config(url="", root="app", target_directory="resized")) def get_books(lim=-1, search="%"): data_dir = Path("app/data/") db = data_dir / "metadata.db" con = sqlite3.connect(db) con.row_factory = sqlite3.Row cursor = con.cursor() if not search: search = "%" sql = f""" SELECT books.id AS id, books.title AS title, books.sort AS sort, authors.name AS author, books.author_sort AS authorSort, books.path AS path, data.name AS file, data.format AS format, books.timestamp AS added,