dangerzone/qubes/dz.ConvertDev
Alex Pyrgiotis c194606550
Add Qubes RPC calls
Add two RPC calls that can run on disposable VMs:

* dz.Convert: This call simply imports the dangerzone package and runs
  the Qubes wrapper for the "document to pixels" code. This call is
  similar to the way we run the conversion part in a container.
* dz.ConvertDev: This call is for development purposes, and does the
  following:
  - First it receives the `dangerzone.conversion` module as Python
    zipfile. This way, we can quickly iterate on changes on the
    server-side part of Qubes, without altering the templates.
  - Second, it calls the Qubes wrapper for the "document to pixels"
    code, as dz.Convert does.
2023-06-21 11:45:08 +03:00

42 lines
918 B
Python
Executable file

#!/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())