Permalink
Browse files

Check for pstopdf if ps2pdf doesnt exist

  • Loading branch information...
root
root committed Oct 12, 2011
1 parent 56d289d commit 2138d4436356474e4039f5e7d1cf1a71b151d482
Showing with 22 additions and 1 deletion.
  1. +22 −1 backend.py
View
@@ -66,9 +66,30 @@
logfile = open('/var/log/cups/cloudprint_log', 'a')
logfile.write("Printing file " + printFile + "\n")
+def which(program):
+ import os
+ def is_exe(fpath):
+ return os.path.exists(fpath) and os.access(fpath, os.X_OK)
+
+ fpath, fname = os.path.split(program)
+ if fpath:
+ if is_exe(program):
+ return program
+ else:
+ for path in os.environ["PATH"].split(os.pathsep):
+ exe_file = os.path.join(path, program)
+ if is_exe(exe_file):
+ return exe_file
+
+ return None
+
+
pdfFile = printFile+".pdf"
+ps2PdfName = "ps2pdf"
+if which(ps2PdfName) == None:
+ ps2PdfName = "pstopdf"
-subprocess.call(["ps2pdf", printFile, pdfFile])
+subprocess.call([ps2PdfName, printFile, pdfFile])
submitjobpath = "/usr/lib/cloudprint-cups/" + "submitjob.py"
if not os.path.exists( submitjobpath ):
submitjobpath = "/usr/local/lib/cloudprint-cups/" + "submitjob.py"

0 comments on commit 2138d44

Please sign in to comment.