Ignore:
Timestamp:
03/26/08 13:59:18 (4 years ago)
Author:
christian
Message:

Added better status messages while printing
Added readme and license to the installer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SipgateFax/trunk/Resources/usr/libexec/cups/backend/sipgate

    r9 r10  
    6060        print 'network sipgate://user:pass@apihost "Unknown" "Sipgate"' 
    6161        sys.exit(CUPS_BACKEND_OK) 
    62          
     62 
    6363if argc < 6 or argc > 7: 
    6464        sys.stderr.write("ERROR: %s job-id user title copies options [file]\n" % sys.argv[0]) 
    6565        sys.exit(CUPS_BACKEND_FAILED) 
    66          
     66 
    6767jobid = sys.argv[1] 
    6868user = sys.argv[2] 
     
    8282        sys.exit(CUPS_BACKEND_CANCEL) 
    8383 
     84sys.stderr.write("INFO: Receiving data\n") 
    8485if argc == 7: 
    85         sys.stderr.write("INFO: file is %s\n" % sys.argv[6]) 
     86        sys.stderr.write("DEBUG: file is %s\n" % sys.argv[6]) 
    8687        infilename = sys.argv[6] 
    8788else: 
    88         sys.stderr.write("INFO: file is stdin\n") 
     89        sys.stderr.write("DEBUG: file is stdin\n") 
    8990        infilename = tempfile.mktemp("sipfax.pdf") 
    9091        try: 
     
    105106cmd = "/System/Library/Printers/Libraries/quartzfilter" 
    106107filterpath = "/Library/Filters/CompressForFax.qfilter" 
     108sys.stderr.write("INFO: Compressing PDF\n") 
    107109ret = os.system("%s \"%s\" \"%s\" \"%s\"" % (cmd, infilename, filterpath, outfilename)) 
    108110if ret == 0: 
     
    119121 
    120122# Identify the client, optional but polite :-) 
     123sys.stderr.write("INFO: Identifying client\n") 
    121124result = server.samurai.ClientIdentify({ 
    122125        'ClientName':'SipgateFax for Mac OSX', 
     
    126129 
    127130if result['StatusCode']!=200: 
    128         sys.stderr.write("ERROR: Unexpected status code while registering client: " + `result['StatusCode']`) 
     131    if result['StatusCode']==403: 
     132        sys.stderr.write("ERROR: User credentials missing or incorrect\n") 
     133        sys.exit(CUPS_BACKEND_HOLD) 
     134         
     135        sys.stderr.write("ERROR: Error while identifying client: %s\n" % `result['StatusString']`) 
    129136        sys.exit(CUPS_BACKEND_FAILED) 
    130137 
    131138# send out the fax 
     139sys.stderr.write("INFO: Sending fax data\n") 
    132140result = server.samurai.SessionInitiate({ 
    133141        'RemoteUri':"sip:%s@sipgate.net" % faxTo, 
     
    137145 
    138146if result['StatusCode']!=200: 
    139         sys.stderr.write("ERROR: Unexpected status code while sending fax: " + `result['StatusCode']`) 
     147        sys.stderr.write("ERROR: Error while sending fax: %s\n" % `result['StatusString']`) 
    140148        sys.exit(CUPS_BACKEND_FAILED) 
    141149 
     
    144152os.unlink(outfilename) 
    145153 
     154sys.stderr.write("INFO: Fax sent successfully\n") 
    146155sys.exit(CUPS_BACKEND_OK) 
Note: See TracChangeset for help on using the changeset viewer.