MCPcopy
hub / github.com/freedomofpress/dangerzone / Dummy

Class Dummy

dangerzone/isolation_provider/dummy.py:24–62  ·  view source on GitHub ↗

Dummy Isolation Provider (FOR TESTING ONLY) "Do-nothing" converter - the sanitized files are the same as the input files. Useful for testing without the need to use docker.

Source from the content-addressed store, hash-verified

22
23
24class Dummy(IsolationProvider):
25 """Dummy Isolation Provider (FOR TESTING ONLY)
26
27 "Do-nothing" converter - the sanitized files are the same as the input files.
28 Useful for testing without the need to use docker.
29 """
30
31 def __init__(self) -> None:
32 # Sanity check
33 if not getattr(sys, "dangerzone_dev", False):
34 raise UnsafeIsolationProvider()
35 super().__init__()
36
37 @staticmethod
38 def requires_install() -> bool:
39 return False
40
41 def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen:
42 cmd = [
43 sys.executable,
44 "-c",
45 "from dangerzone.isolation_provider.dummy import dummy_script;"
46 " dummy_script()",
47 ]
48 return subprocess.Popen(
49 cmd,
50 stdin=subprocess.PIPE,
51 stdout=subprocess.PIPE,
52 stderr=self.proc_stderr,
53 start_new_session=True,
54 )
55
56 def terminate_doc_to_pixels_proc(
57 self, document: Document, p: subprocess.Popen
58 ) -> None:
59 terminate_process_group(p)
60
61 def get_max_parallel_conversions(self) -> int:
62 return 1

Callers 4

test_ocr_ommisionsFunction · 0.90
providerFunction · 0.90
runFunction · 0.85
runFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_ocr_ommisionsFunction · 0.72
providerFunction · 0.72