Changeset 1918 for pykota/trunk/bin/cupspykota
- Timestamp:
- 11/15/04 20:59:34 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1902 r1918 24 24 # 25 25 # $Log$ 26 # Revision 1.78 2004/11/15 19:59:34 jalet 27 # PyKota banners now basically work ! 28 # 26 29 # Revision 1.77 2004/11/06 22:40:57 jalet 27 30 # Safer code … … 469 472 # launches the pre hook 470 473 self.prehook(userpquota) 471 474 475 # saves the size of banners which have to be accounted for 476 # this is needed in the case of software accounting 477 bannersize = 0 478 479 # handle starting banner pages before accounting 480 accountbanner = self.config.getAccountBanner(printer.Name) 481 if accountbanner in ["ENDING", "NONE"] : 482 banner = self.startingBanner(printer.Name) 483 if banner : 484 self.logdebug("Printing starting banner before accounting begins.") 485 self.handleData(banner) 486 472 487 self.printMoreInfo(user, printer, _("Job accounting begins.")) 473 488 self.accounter.beginJob(printer) 489 490 # handle starting banner pages during accounting 491 if accountbanner in ["STARTING", "BOTH"] : 492 banner = self.startingBanner(printer.Name) 493 if banner : 494 self.logdebug("Printing starting banner during accounting.") 495 self.handleData(banner) 496 if self.accounter.isSoftware : 497 bannersize += 1 # TODO : fix this by passing the banner's content through PDLAnalyzer 474 498 else : 475 499 action = "ALLOW" … … 489 513 os.environ["PYKOTAPHASE"] = "AFTER" 490 514 515 # handle ending banner pages during accounting 516 if accountbanner in ["ENDING", "BOTH"] : 517 banner = self.endingBanner(printer.Name) 518 if banner : 519 self.logdebug("Printing ending banner during accounting.") 520 self.handleData(banner) 521 if self.accounter.isSoftware : 522 bannersize += 1 # TODO : fix this by passing the banner's content through PDLAnalyzer 523 491 524 # stops accounting. 492 525 self.accounter.endJob(printer) 493 526 self.printMoreInfo(user, printer, _("Job accounting ends.")) 494 527 528 # handle ending banner pages after accounting ends 529 if accountbanner in ["STARTING", "NONE"] : 530 banner = self.endingBanner(printer.Name) 531 if banner : 532 self.logdebug("Printing ending banner after accounting ends.") 533 self.handleData(banner) 534 495 535 # retrieve the job size 496 536 if action == "DENY" : … … 498 538 self.printMoreInfo(user, printer, _("Job size forced to 0 because printing is denied.")) 499 539 else : 500 jobsize = self.accounter.getJobSize(printer) 540 jobsize = self.accounter.getJobSize(printer) + bannersize 501 541 self.printMoreInfo(user, printer, _("Job size : %i") % jobsize) 502 542 … … 549 589 return "%s (%s)" % (fd, " | ".join(maskval)) 550 590 551 def handleData(self ) :591 def handleData(self, filehandle=None) : 552 592 """Pass the job's data to the real backend.""" 553 593 # Find the real backend pathname … … 578 618 totalfromchild = totaltocups = 0 579 619 580 if self.preserveinputfile is None : 581 # this is not a real file, we read the job's data 582 # from our temporary file which is a copy of stdin 583 infno = self.jobdatastream.fileno() 584 self.jobdatastream.seek(0) 585 pollster.register(infno, select.POLLIN | select.POLLPRI) 586 else : 587 # job's data is in a file, no need to pass the data 588 # to the real backend 589 self.logdebug("Job's data is in %s" % self.preserveinputfile) 620 if filehandle is None: 621 if self.preserveinputfile is None : 622 # this is not a real file, we read the job's data 623 # from our temporary file which is a copy of stdin 624 infno = self.jobdatastream.fileno() 625 self.jobdatastream.seek(0) 626 pollster.register(infno, select.POLLIN | select.POLLPRI) 627 else : 628 # job's data is in a file, no need to pass the data 629 # to the real backend 630 self.logdebug("Job's data is in %s" % self.preserveinputfile) 631 infno = None 632 endinput = 1 633 else: 634 self.logdebug("Printing data passed from filehandle") 635 indata = filehandle.read() 590 636 infno = None 591 637 endinput = 1 638 filehandle.close() 592 639 593 640 self.logdebug("Entering streams polling loop...")