diff --git a/qubes/dz.Convert b/qubes/dz.Convert new file mode 100755 index 0000000..d6b2e3e --- /dev/null +++ b/qubes/dz.Convert @@ -0,0 +1,2 @@ +#!/bin/sh +python -m dangerzone.conversion.doc_to_pixels_qubes_wrapper diff --git a/qubes/dz.ConvertDev b/qubes/dz.ConvertDev new file mode 100755 index 0000000..a663081 --- /dev/null +++ b/qubes/dz.ConvertDev @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +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_qubes_wrapper import main + return asyncio.run(main()) + + +if __name__ == "__main__": + sys.exit(main())