]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/svg2pdftex.py
Fixes for Japanese documents
[lyx.git] / lib / scripts / svg2pdftex.py
index 06b542891ccbf642e3659e5ee1a70fa37d247d30..86564fac2f27b83f9b525b28cc76db8f65a2ca95 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file svg2pdftex.py
 #   the real PDF file would be overwritten by a TeX file named outputfile.pdf.
 #
 
-import os, sys, re
+from __future__ import print_function
+
+import os, sys, re, subprocess
 
 def runCommand(cmd):
     ''' Utility function:
         run a command, quit if fails
     '''
-    if os.system(cmd) != 0:
-        print "Command '%s' fails." % cmd
+    res = subprocess.check_call(cmd)
+    if res != 0:
+        print("Command '%s' fails (exit code: %i)." % (res.cmd, res.returncode))
         sys.exit(1)
 
 InkscapeCmd = "inkscape"
@@ -65,7 +68,7 @@ OutBase = os.path.splitext(OutputFile)[0]
 # while outsourcing the text to a LaTeX file ${OutBase}.pdf_tex which includes and overlays
 # the PDF image and can be \input to LaTeX files. We rename the latter file to ${OutputFile}
 # (although this is probably the name it already has).
-runCommand('%s --file=%s --export-pdf=%s.pdf --export-latex' % (InkscapeCmd, InputFile, OutBase))
+runCommand([r'%s' % InkscapeCmd, '--file=%s' % InputFile, '--export-pdf=%s.pdf' % OutBase, '--export-latex'])
 
 os.rename('%s.pdf_tex' % OutBase, OutputFile)