dangerzone/qubes/dz.ConvertDev
deeplow 0a099540c8
Stream pages in containers: merge isolation providers
Merge Qubes and Containers isolation providers core code into the class
parent IsolationProviders abstract class.

This is done by streaming pages in containers for exclusively in first
conversion process. The commit is rather large due to the multiple
interdependencies of the code, making it difficult to split into various
commits.

The main conversion method (_convert) now in the superclass simply calls
two methods:
  - doc_to_pixels()
  - pixels_to_pdf()

Critically, doc_to_pixels is implemented in the superclass, diverging
only in a specialized method called "start_doc_to_pixels_proc()". This
method obtains the process responsible that communicates with the
isolation provider (container / disp VM) via `podman/docker` and qrexec
on Containers and Qubes respectively.

Known regressions:
  - progress reports stopped working on containers

Fixes #443
2024-02-06 19:42:33 +00:00

42 lines
905 B
Python
Executable file

#!/usr/bin/env python3
import asyncio
import glob
import io
import os
import sys
import tempfile
import zipfile
def say(msg):
print(msg, file=sys.stderr, flush=True)
def main():
say("Debugging mode enabled")
# Get the size of the zipfile
size = int.from_bytes(sys.stdin.buffer.read(4))
say(f"Reading {size} bytes of Python zipfile")
# Read the zipfile from stdin
zf = sys.stdin.buffer.read(size)
if len(zf) < size:
say(f"Client closed the connection early")
return 1
with tempfile.NamedTemporaryFile(suffix=".zip") as t:
say(f"Storing the Python zipfile to {t.name}")
t.write(zf)
t.flush()
say(f"Importing the conversion module")
sys.path.insert(0, t.name)
from dangerzone.conversion.doc_to_pixels import main
return asyncio.run(main())
if __name__ == "__main__":
sys.exit(main())