From 01d9d4a8e9fa2bb07878492da066d32f113377c9 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Wed, 9 Oct 2024 18:00:24 +0300 Subject: [PATCH] FIXUP: Switch to logging statements --- install/linux/vendor-pymupdf.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/install/linux/vendor-pymupdf.py b/install/linux/vendor-pymupdf.py index 86de8caf5..0c497203f 100755 --- a/install/linux/vendor-pymupdf.py +++ b/install/linux/vendor-pymupdf.py @@ -1,11 +1,14 @@ #!/usr/bin/env python3 import argparse +import logging import os import subprocess import sys from pathlib import Path +logger = logging.getLogger(__name__) + DZ_VENDOR_DIR = Path("./dangerzone/vendor") @@ -18,7 +21,13 @@ def main(): ) args = parser.parse_args() - print(">>> Getting PyMuPDF deps as requirements.txt", file=sys.stderr) + logging.basicConfig( + level=logging.DEBUG, + format="%(asctime)s - %(levelname)s - %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", + ) + + logger.info("Getting PyMuPDF deps as requirements.txt") cmd = ["poetry", "export", "--only", "container"] container_requirements_txt = subprocess.check_output(cmd) @@ -39,7 +48,7 @@ def main(): if sys.version.startswith("3.8"): container_requirements_txt = container_requirements_txt.replace(b"3.9", b"3.8") - print(f">>> Vendoring PyMuPDF under '{args.dest}'", file=sys.stderr) + logger.info(f"Vendoring PyMuPDF under '{args.dest}'") # We prefer to call the CLI version of `pip`, instead of importing it directly, as # instructed here: # https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program @@ -58,10 +67,9 @@ def main(): subprocess.run(cmd, check=True, input=container_requirements_txt) if not os.listdir(args.dest): - print(f">>> Failed to vendor PyMuPDF under '{args.dest}'", file=sys.stderr) - + logger.error(f"Failed to vendor PyMuPDF under '{args.dest}'") - print(f">>> Successfully vendored PyMuPDF under '{args.dest}'", file=sys.stderr) + logger.info(f"Successfully vendored PyMuPDF under '{args.dest}'") if __name__ == "__main__":