]> git.lyx.org Git - features.git/commitdiff
Port gnuplot2pdf.py to Python 3
authorScott Kostyshak <skostysh@lyx.org>
Fri, 30 Aug 2019 00:48:34 +0000 (20:48 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Wed, 4 Sep 2019 13:12:09 +0000 (09:12 -0400)
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.

lib/scripts/gnuplot2pdf.py

index fb036b2df5a758fada52e6a9dfc1bf853a238411..e7246a3deaedecae2c5c96710ac3966fd93d50ce 100755 (executable)
@@ -11,7 +11,7 @@ if (len(argv) != 3):
 
 with open(argv[1], 'rb') as fsrc:
     subproc = Popen("gnuplot", shell=True, stdin=PIPE)
-    subproc.stdin.write("set terminal pdf\nset output '%s'\n" % argv[2])
+    subproc.stdin.write(b"set terminal pdf\nset output '%s'\n" % argv[2].encode())
     shutil.copyfileobj(fsrc, subproc.stdin)
-    subproc.stdin.write("exit\n")
-    subproc.wait()
+    subproc.stdin.write(b"exit\n")
+    subproc.communicate()