dangerzone/qubes/dz.ConvertDev
Alexis Métaireau 99f1e15fd2
chore: Do not use fstrings without placeholders
> f-strings are a convenient way to format strings, but they are not
> necessary if there are no placeholder expressions to format. In this
> case, a regular string should be used instead, as an f-string without
> placeholders can be confusing for readers, who may expect such a
> placeholder to be present.
>
> — [ruff docs](https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/)
2024-06-05 14:19:31 +02:00

39 lines
853 B
Python
Executable file

#!/usr/bin/python3
import asyncio
import sys
import tempfile
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("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("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())