From dc8a22c8e73411c3c4b1fc7b46995ebac7d80dd8 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Thu, 26 Sep 2024 17:37:02 +0300 Subject: [PATCH] Fix the dummy provider Make the dummy provider behave a bit more like the other providers, with a proper function and termination logic. This will be helpful soon in the tests. --- dangerzone/isolation_provider/dummy.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dangerzone/isolation_provider/dummy.py b/dangerzone/isolation_provider/dummy.py index cd2174318..80dd17fcf 100644 --- a/dangerzone/isolation_provider/dummy.py +++ b/dangerzone/isolation_provider/dummy.py @@ -8,7 +8,7 @@ from ..document import Document from ..util import get_resource_path -from .base import IsolationProvider +from .base import IsolationProvider, terminate_process_group log = logging.getLogger(__name__) @@ -27,6 +27,7 @@ def __init__(self) -> None: "Dummy isolation provider is UNSAFE and should never be " + "called in a non-testing system." ) + super().__init__() def install(self) -> bool: return True @@ -73,12 +74,19 @@ def pixels_to_pdf( pass def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen: - return subprocess.Popen("True", start_new_session=True) + dummy_cmd = ["python3", "-c", "print('The cake is a lie')"] + return subprocess.Popen( + dummy_cmd, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=self.proc_stderr, + start_new_session=True, + ) def terminate_doc_to_pixels_proc( self, document: Document, p: subprocess.Popen ) -> None: - pass + terminate_process_group(p) def get_max_parallel_conversions(self) -> int: return 1