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.
This commit is contained in:
Alex Pyrgiotis 2023-10-02 15:31:01 +03:00
parent 16603875d6
commit b7b76174ab
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -24,7 +24,12 @@ from ..util import (
get_tmp_dir, get_tmp_dir,
nonblocking_read, 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__) log = logging.getLogger(__name__)
@ -167,6 +172,14 @@ class Qubes(IsolationProvider):
asyncio.run(converter.convert(ocr_lang)) asyncio.run(converter.convert(ocr_lang))
except (RuntimeError, TimeoutError, ValueError) as e: except (RuntimeError, TimeoutError, ValueError) as e:
raise errors.UnexpectedConversionError(str(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) shutil.move(CONVERTED_FILE_PATH, document.output_filename)
success = True success = True