Skip to content

Commit

Permalink
Fix the dummy provider
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apyrgio committed Oct 7, 2024
1 parent d641065 commit dc8a22c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dangerzone/isolation_provider/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit dc8a22c

Please sign in to comment.