mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
db65b1a3c3
Instead of wait(), use communicate(), as mentioned here: https://docs.python.org/3/library/subprocess.html Otherwise, the process seems to hang as cautioned in the above URL. Also, use byte strings.
18 lines
489 B
Python
Executable File
18 lines
489 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
from subprocess import Popen, PIPE
|
|
from sys import argv, stderr, exit
|
|
import os
|
|
import shutil
|
|
|
|
if (len(argv) != 3):
|
|
stderr.write("Usage: %s <src_file> <dst_file>\n" % argv[0])
|
|
exit(1)
|
|
|
|
with open(argv[1], 'rb') as fsrc:
|
|
subproc = Popen("gnuplot", shell=True, stdin=PIPE)
|
|
subproc.stdin.write(b"set terminal pdf\nset output '%s'\n" % argv[2].encode())
|
|
shutil.copyfileobj(fsrc, subproc.stdin)
|
|
subproc.stdin.write(b"exit\n")
|
|
subproc.communicate()
|