From b7b76174ab6fe9b8df8dd612e60e4ca222de1706 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Mon, 2 Oct 2023 15:31:01 +0300 Subject: [PATCH] qubes: Log captured output for the second stage Log the captured command output during the second stage, only in dev environments. This follows what we have already done for the first stage. --- dangerzone/isolation_provider/qubes.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dangerzone/isolation_provider/qubes.py b/dangerzone/isolation_provider/qubes.py index 58baec1..e2cfc43 100644 --- a/dangerzone/isolation_provider/qubes.py +++ b/dangerzone/isolation_provider/qubes.py @@ -24,7 +24,12 @@ from ..util import ( get_tmp_dir, nonblocking_read, ) -from .base import MAX_CONVERSION_LOG_CHARS, IsolationProvider +from .base import ( + MAX_CONVERSION_LOG_CHARS, + PIXELS_TO_PDF_LOG_END, + PIXELS_TO_PDF_LOG_START, + IsolationProvider, +) log = logging.getLogger(__name__) @@ -167,6 +172,14 @@ class Qubes(IsolationProvider): asyncio.run(converter.convert(ocr_lang)) except (RuntimeError, TimeoutError, ValueError) as e: raise errors.UnexpectedConversionError(str(e)) + finally: + if getattr(sys, "dangerzone_dev", False): + out = converter.captured_output.decode() + text = ( + f"Conversion output: (pixels to PDF)\n" + f"{PIXELS_TO_PDF_LOG_START}\n{out}{PIXELS_TO_PDF_LOG_END}" + ) + log.info(text) shutil.move(CONVERTED_FILE_PATH, document.output_filename) success = True