##// END OF EJS Templates
Mac OSX support for svg converter
Jonathan Frederic -
Show More
@@ -23,7 +23,8 b' from .convertfigures import ConvertFiguresTransformer'
23 # Constants
23 # Constants
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25
25
26 INKSCAPE_COMMAND = "inkscape --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\""
26 INKSCAPE_COMMAND = 'inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"'
27 INKSCAPE_OSX_COMMAND = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"'
27
28
28
29
29 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
@@ -56,10 +57,15 b' class ConvertSvgTransformer(ConvertFiguresTransformer):'
56 with open(input_filename, 'w') as f:
57 with open(input_filename, 'w') as f:
57 f.write(data)
58 f.write(data)
58
59
60 #Determine command (different on Mac OSX)
61 command = INKSCAPE_COMMAND
62 if sys.platform == 'darwin':
63 command = INKSCAPE_OSX_COMMAND
64
59 #Call conversion application
65 #Call conversion application
60 output_filename = os.path.join(tmpdir, 'figure.pdf')
66 output_filename = os.path.join(tmpdir, 'figure.pdf')
61 shell = INKSCAPE_COMMAND.format(from_filename=input_filename,
67 shell = command.format(from_filename=input_filename,
62 to_filename=output_filename)
68 to_filename=output_filename)
63 subprocess.call(shell, shell=True) #Shell=True okay since input is trusted.
69 subprocess.call(shell, shell=True) #Shell=True okay since input is trusted.
64
70
65 #Read output from drive
71 #Read output from drive
General Comments 0
You need to be logged in to leave comments. Login now