Permalink
Browse files

Added error messages that pass-through correctly to CUPS

  • Loading branch information...
simoncadman committed Nov 7, 2011
1 parent 490eb89 commit 835bebcf09ff14cc87ea348d501ba76dfbccd6da
Showing with 16 additions and 4 deletions.
  1. +13 −1 backend.py
  2. +3 −3 submitjob.py
View
@@ -89,18 +89,30 @@ def is_exe(fpath):
if which(ps2PdfName) == None:
ps2PdfName = "pstopdf"
+sys.stderr.write( "INFO: Converting print job to PDF\n")
+
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"
logfile.write("Running " + submitjobpath + "\n")
logfile.write("Converted to PDF as "+ pdfFile + "\n")
+
+sys.stderr.write( "INFO: Sending document to Cloud Print\n")
logfile.write("Sending "+ pdfFile + " to cloud\n")
-subprocess.call([submitjobpath, pdfFile, uri])
+result = 0
+p = subprocess.Popen([submitjobpath, pdfFile, uri], stdout=subprocess.PIPE)
+output = p.communicate()[0]
+result = p.returncode
+sys.stderr.write(output)
+logfile.write(output)
logfile.write(pdfFile + " sent to cloud print, deleting\n")
os.unlink( printFile )
+sys.stderr.write("INFO: Cleaning up temporary files\n")
logfile.write("Deleted "+ printFile + "\n")
os.unlink( pdfFile )
logfile.write("Deleted "+ pdfFile + "\n")
logfile.close()
+sys.stderr.write("INFO: Printing Successful\n")
+sys.exit(result)
View
@@ -447,10 +447,10 @@ def GetUrl(url, tokens, data=None, cookies=False, anonymous=False):
printerid = getPrinter(printername)
if printerid == None:
- print "Printer not found"
+ print "ERROR: Printer '" + printername + "' not found"
sys.exit(1)
if SubmitJob(printerid, 'pdf', sys.argv[1]):
- print "Successfully printed"
+ print "INFO: Successfully printed"
sys.exit(0)
else:
- print "Failed to submit job"
+ print "ERROR: Failed to submit job to cloud print"

0 comments on commit 835bebc

Please sign in to comment.