File: gnuplot2pdf.py

package info (click to toggle)
lyx 2.5.0~RC2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 138,212 kB
  • sloc: cpp: 244,227; ansic: 106,398; xml: 72,791; python: 39,384; sh: 7,666; makefile: 6,586; pascal: 2,143; perl: 2,101; objc: 1,084; tcl: 163; sed: 16
file content (16 lines) | stat: -rwxr-xr-x 480 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python3

from subprocess import Popen, PIPE
from sys import argv, stderr, exit
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()