mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
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.
This commit is contained in:
parent
d6410652cb
commit
dc8a22c8e7
1 changed files with 11 additions and 3 deletions
|
@ -8,7 +8,7 @@ from typing import Callable, Optional
|
||||||
|
|
||||||
from ..document import Document
|
from ..document import Document
|
||||||
from ..util import get_resource_path
|
from ..util import get_resource_path
|
||||||
from .base import IsolationProvider
|
from .base import IsolationProvider, terminate_process_group
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class Dummy(IsolationProvider):
|
||||||
"Dummy isolation provider is UNSAFE and should never be "
|
"Dummy isolation provider is UNSAFE and should never be "
|
||||||
+ "called in a non-testing system."
|
+ "called in a non-testing system."
|
||||||
)
|
)
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
def install(self) -> bool:
|
def install(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
@ -73,12 +74,19 @@ class Dummy(IsolationProvider):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen:
|
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(
|
def terminate_doc_to_pixels_proc(
|
||||||
self, document: Document, p: subprocess.Popen
|
self, document: Document, p: subprocess.Popen
|
||||||
) -> None:
|
) -> None:
|
||||||
pass
|
terminate_process_group(p)
|
||||||
|
|
||||||
def get_max_parallel_conversions(self) -> int:
|
def get_max_parallel_conversions(self) -> int:
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in a new issue