From 2b4b89a155e8fb26aa8e4eb94f5efc147c47efcb Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Thu, 14 Mar 2024 10:44:45 +0200 Subject: [PATCH] Update the way we get debug logs Move the logic for grabbing debug logs to a new place, now that we have merged the two conversion stages (doc to pixels, pixels to PDF). --- dangerzone/isolation_provider/base.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/dangerzone/isolation_provider/base.py b/dangerzone/isolation_provider/base.py index b66162b..1899e76 100644 --- a/dangerzone/isolation_provider/base.py +++ b/dangerzone/isolation_provider/base.py @@ -225,17 +225,6 @@ class IsolationProvider(ABC): text = "Converted document" self.print_progress(document, False, text, percentage) - if getattr(sys, "dangerzone_dev", False): - assert p.stderr - debug_log = read_debug_text(p.stderr, MAX_CONVERSION_LOG_CHARS) - p.stderr.close() - log.info( - "Conversion output (doc to pixels)\n" - f"{DOC_TO_PIXELS_LOG_START}\n" - f"{debug_log}" # no need for an extra newline here - f"{DOC_TO_PIXELS_LOG_END}" - ) - @abstractmethod def pixels_to_pdf( self, document: Document, tempdir: str, ocr_lang: Optional[str] @@ -356,6 +345,15 @@ class IsolationProvider(ABC): document, p, timeout_grace=timeout_grace, timeout_force=timeout_force ) + if getattr(sys, "dangerzone_dev", False): + assert p.stderr + debug_log = read_debug_text(p.stderr, MAX_CONVERSION_LOG_CHARS) + log.info( + "Conversion output (doc to pixels)\n" + f"{DOC_TO_PIXELS_LOG_START}\n" + f"{debug_log}" # no need for an extra newline here + f"{DOC_TO_PIXELS_LOG_END}" + ) # From global_common: