Skip to content

Commit

Permalink
FIXUP: Switch to logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
apyrgio committed Oct 9, 2024
1 parent 40eab9d commit 01d9d4a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions install/linux/vendor-pymupdf.py
Original file line number Diff line number Diff line change
@@ -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")


Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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__":
Expand Down

0 comments on commit 01d9d4a

Please sign in to comment.