Bopytex/bopytex/worker/join_pdf.py

34 lines
912 B
Python
Raw Normal View History

2022-04-13 08:46:53 +00:00
import subprocess
2022-05-07 14:55:33 +00:00
from bopytex.message import Message, SubprocessMessage
2022-04-13 10:26:04 +00:00
2022-04-13 08:46:53 +00:00
def pdfjam(args: dict, deps, output):
joining_process = subprocess.Popen(
["pdfjam"] + deps + ["-o", output],
2022-04-13 08:46:53 +00:00
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
)
2022-05-07 14:55:33 +00:00
return Message(
joining_process.wait(),
list(joining_process.stdout),
list(joining_process.stderr),
)
2022-04-13 08:46:53 +00:00
def gs(args: dict, deps, output):
""" Not working. The command works in terminal but not here """
joining_process = subprocess.Popen(
["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"]
+ deps,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
)
return Message(
joining_process.wait(),
list(joining_process.stdout),
list(joining_process.stderr),
)