+
+/*
+A typical script looks like:
+
+#!/usr/bin/env python
+import os, sys
+
+def unlinkNoThrow(file):
+ ''' remove a file, do not throw if error occurs '''
+ try:
+ os.unlink(file)
+ except:
+ pass
+
+infile = '/home/username/Figure3a.eps'
+infile_base = '/home/username/Figure3a'
+outfile = '/tmp/lyx_tmpdir12992hUwBqt/gconvert0129929eUBPm.pdf'
+
+if os.system(r'epstopdf ' + '"' + infile + '"' + ' --output ' + '"' + outfile + '"' + '') != 0:
+ unlinkNoThrow(outfile)
+ sys.exit(1)
+
+if not os.path.isfile(outfile):
+ if os.path.isfile(outfile + '.0'):
+ os.rename(outfile + '.0', outfile)
+ import glob
+ for file in glob.glob(outfile + '.?'):
+ unlinkNoThrow(file)
+ else:
+ sys.exit(1)
+
+fromfile = outfile
+tofile = '/tmp/lyx_tmpdir12992hUwBqt/Figure3a129927ByaCl.ppm'
+
+try:
+ os.rename(fromfile, tofile)
+except:
+ import shutil
+ try:
+ shutil.copy(fromfile, tofile)
+ except:
+ sys.exit(1)
+ unlinkNoThrow(fromfile)
+
+*/