Changeset 2891 for pykota/trunk/bin/cupspykota
- Timestamp:
- 05/22/06 23:32:15 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2889 r2891 47 47 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 48 48 from pykota.accounter import openAccounter 49 from pykota.ipp import IPPRequest, IPPError 50 49 # TODO : remove the three lines below and the code which handles 50 # TODO : them in a future release. 51 from pykota.ipp import IPPRequest as oldIPPRequest 52 from pykota.ipp import IPPError as oldIPPError 53 54 try : 55 from pkipplib import pkipplib 56 except ImportError : 57 haspkipplib = False 58 else : 59 haspkipplib = True 60 51 61 class FakeObject : 52 62 """Fake object.""" … … 272 282 (self.myname, self.PrinterName, self.UserName, self.JobId)) 273 283 274 (ippfilename, ippmessage) = self.parseIPPRequestFile() 275 self.ControlFile = ippfilename 276 john = ippmessage.operation_attributes.get("job-originating-host-name", \ 277 ippmessage.job_attributes.get("job-originating-host-name", \ 278 (None, None))) 284 if not haspkipplib : 285 (ippfilename, ippmessage) = self.parseIPPRequestFile() 286 self.ControlFile = ippfilename 287 john = ippmessage.operation_attributes.get("job-originating-host-name", \ 288 ippmessage.job_attributes.get("job-originating-host-name", \ 289 (None, None))) 290 jbing = ippmessage.job_attributes.get("job-billing", (None, None)) 291 else : 292 cupsserver = pkipplib.CUPS(url="http://%s:%s" % \ 293 (os.environ.get("CUPS_SERVER", "localhost"), \ 294 os.environ.get("IPP_PORT", "631"))) 295 answer = cupsserver.getJobAttributes(self.JobId) 296 self.ControlFile = "NotUsedAnymore" 297 try : 298 john = answer.job["job-originating-host-name"] 299 except KeyError : 300 try : 301 john = answer.operation["job-originating-host-name"] 302 except KeyError : 303 john = (None, None) 304 try : 305 jbing = answer.job["job-billing"] 306 except KeyError : 307 jbing = (None, None) 279 308 if type(john) == type([]) : 280 309 john = john[-1] 281 310 (chtype, self.ClientHost) = john 282 jbing = ippmessage.job_attributes.get("job-billing", (None, None))283 311 if type(jbing) == type([]) : 284 312 jbing = jbing[-1] … … 520 548 self.logdebug("Parsing of IPP request file %s begins." % ippmessagefile) 521 549 try : 522 ippmessage = IPPRequest(ippdatafile.read())550 ippmessage = oldIPPRequest(ippdatafile.read()) 523 551 ippmessage.parse() 524 except IPPError, msg :552 except oldIPPError, msg : 525 553 self.printInfo("Error while parsing %s : %s" \ 526 554 % (ippmessagefile, msg), "warn")