diff --git a/chanbans/__main__.py b/chanbans/__main__.py index 84ee29d..eae9557 100644 --- a/chanbans/__main__.py +++ b/chanbans/__main__.py @@ -2,6 +2,7 @@ import asyncio import argparse import logging +from . import config from .pull import pull from .http import run_app from .hist import generate_histogram_svg @@ -33,7 +34,7 @@ def parse_args(): ) pull_parser.add_argument( "--generate-histogram", - action="store_true", + type=lambda x: x.lower() in ['true', '1', 'yes', 'y'], help="Generate a histogram SVG if any new posts are pulled", default=config.PULL_GENERATE_HISTOGRAM, ) @@ -75,7 +76,7 @@ def main(): case "serve": run_app() case "hist": - generate_histogram_svg() + generate_histogram_svg(config.HISTOGRAM_PATH) case command: assert ( False diff --git a/chanbans/config.py b/chanbans/config.py index 555442c..1159976 100644 --- a/chanbans/config.py +++ b/chanbans/config.py @@ -51,7 +51,7 @@ HTTP_RESULTS_PER_PAGE = default("HTTP_RESULTS_PER_PAGE", 100) STATIC_HANDLER = one_of_default("STATIC_HANDLER", ("remote", "local"), "local") STATIC_LOCAL_PATH = Path(default("STATIC_LOCAL_PATH", "static")) -STATIC_LOCAL_FOLLOW_SYMLINKS = default_bool("STATIC_LOCAL_FOLLOW_SYMLINKS") +STATIC_LOCAL_FOLLOW_SYMLINKS = default_bool("STATIC_LOCAL_FOLLOW_SYMLINKS", default_value=True) STATIC_ROOT = default("STATIC_ROOT", "/static") HISTOGRAM_PATH = Path(default("HISTOGRAM_PATH", "static/histogram.svg")) diff --git a/chanbans/hist.py b/chanbans/hist.py index 0d430dd..f2e8c99 100644 --- a/chanbans/hist.py +++ b/chanbans/hist.py @@ -35,7 +35,7 @@ def histogram_svg(): return svg -def generate_histogram_svg(path: Path = HISTOGRAM_PATH): +def generate_histogram_svg(path: Path): log.info("Generating and writing histogram SVG to %s", path) svg = histogram_svg() path = path.write_text(svg) diff --git a/chanbans/pull.py b/chanbans/pull.py index a3270ad..b90f4f3 100644 --- a/chanbans/pull.py +++ b/chanbans/pull.py @@ -47,7 +47,10 @@ async def get_thumb(thumb_path: Union[str, Path], post: dict) -> Optional[bytes] return content -async def pull(generate_histogram: bool = config.GENERATE_HISTOGRAM): +async def pull( + generate_histogram: bool = config.PULL_GENERATE_HISTOGRAM, + histogram_path: Path = config.HISTOGRAM_PATH, +): # TODO(args) --db-path arg db = get_db() @@ -209,7 +212,7 @@ async def pull(generate_histogram: bool = config.GENERATE_HISTOGRAM): log.exception("error inserting data") log.info("Continuing") if updated and generate_histogram: - generate_histogram_svg() + generate_histogram_svg(histogram_path) # Finish off thumbnail jobs await asyncio.gather(*download_jobs)