Changeset 10 for SipgateFax/trunk/Resources
- Timestamp:
- 03/26/08 13:59:18 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SipgateFax/trunk/Resources/usr/libexec/cups/backend/sipgate
r9 r10 60 60 print 'network sipgate://user:pass@apihost "Unknown" "Sipgate"' 61 61 sys.exit(CUPS_BACKEND_OK) 62 62 63 63 if argc < 6 or argc > 7: 64 64 sys.stderr.write("ERROR: %s job-id user title copies options [file]\n" % sys.argv[0]) 65 65 sys.exit(CUPS_BACKEND_FAILED) 66 66 67 67 jobid = sys.argv[1] 68 68 user = sys.argv[2] … … 82 82 sys.exit(CUPS_BACKEND_CANCEL) 83 83 84 sys.stderr.write("INFO: Receiving data\n") 84 85 if 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]) 86 87 infilename = sys.argv[6] 87 88 else: 88 sys.stderr.write(" INFO: file is stdin\n")89 sys.stderr.write("DEBUG: file is stdin\n") 89 90 infilename = tempfile.mktemp("sipfax.pdf") 90 91 try: … … 105 106 cmd = "/System/Library/Printers/Libraries/quartzfilter" 106 107 filterpath = "/Library/Filters/CompressForFax.qfilter" 108 sys.stderr.write("INFO: Compressing PDF\n") 107 109 ret = os.system("%s \"%s\" \"%s\" \"%s\"" % (cmd, infilename, filterpath, outfilename)) 108 110 if ret == 0: … … 119 121 120 122 # Identify the client, optional but polite :-) 123 sys.stderr.write("INFO: Identifying client\n") 121 124 result = server.samurai.ClientIdentify({ 122 125 'ClientName':'SipgateFax for Mac OSX', … … 126 129 127 130 if 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']`) 129 136 sys.exit(CUPS_BACKEND_FAILED) 130 137 131 138 # send out the fax 139 sys.stderr.write("INFO: Sending fax data\n") 132 140 result = server.samurai.SessionInitiate({ 133 141 'RemoteUri':"sip:%s@sipgate.net" % faxTo, … … 137 145 138 146 if 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']`) 140 148 sys.exit(CUPS_BACKEND_FAILED) 141 149 … … 144 152 os.unlink(outfilename) 145 153 154 sys.stderr.write("INFO: Fax sent successfully\n") 146 155 sys.exit(CUPS_BACKEND_OK)
Note: See TracChangeset
for help on using the changeset viewer.
