- Timestamp:
- 11/15/04 20:59:34 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 5 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...") -
pykota/trunk/bin/pkbanner
r1911 r1918 24 24 # 25 25 # $Log$ 26 # Revision 1.4 2004/11/15 19:59:34 jalet 27 # PyKota banners now basically work ! 28 # 26 29 # Revision 1.3 2004/11/12 23:46:44 jalet 27 30 # Heavy work on pkbanner. Not finished yet though, but mostly works. … … 39 42 import os 40 43 import cStringIO 44 import popen2 41 45 42 46 try : … … 198 202 self.printInfo("Unknown page size %s, defaulting to A4." % options["pagesize"], "warn") 199 203 204 self.logdebug("Generating the banner in PDF format...") 200 205 doc = self.genPDF(pagesize, options["logo"], options["url"].strip()) 201 print doc 206 207 self.logdebug("Converting the banner to PostScript...") 208 os.environ["PATH"] = "%s:/bin:/usr/bin:/usr/local/bin:/opt/bin:/sbin:/usr/sbin" % os.environ.get("PATH", "") 209 child = popen2.Popen3("gs -q -dNOPAUSE -dBATCH -dPARANOIDSAFER -sDEVICE=pswrite -sOutputFile=- - 2>/tmp/errgs") 210 child.tochild.write(doc) 211 child.tochild.close() 212 sys.stdout.write(child.fromchild.read()) 213 sys.stdout.flush() 214 child.fromchild.close() 215 status = child.wait() 216 if os.WIFEXITED(status) : 217 status = os.WEXITSTATUS(status) 218 self.logdebug("PDF to PostScript converter exit code is %s" % str(status)) 219 self.logdebug("Banner completed.") 220 return status 202 221 203 222 def getInfo(name) : -
pykota/trunk/MANIFEST.in
r1911 r1918 1 include README FAQ COPYING LICENSE TODO NEWS CREDITS SECURITY MANIFEST.in clean.sh checkdeps.py bin/ autopykota bin/dumpykota bin/lprngpykota bin/cupspykota bin/edpykota bin/warnpykota bin/repykota bin/pykotme bin/pykosd bin/pkprinters bin/pkhint bin/pkpgcounter bin/snmpprinterstatus bin/waitprinter.sh bin/papwaitprinter.sh bin/mailandpopup.sh bin/README1 include README FAQ COPYING LICENSE TODO NEWS CREDITS SECURITY MANIFEST.in clean.sh checkdeps.py bin/pkbanner bin/autopykota bin/dumpykota bin/lprngpykota bin/cupspykota bin/edpykota bin/warnpykota bin/repykota bin/pykotme bin/pykosd bin/pkprinters bin/pkhint bin/pkpgcounter bin/snmpprinterstatus bin/waitprinter.sh bin/papwaitprinter.sh bin/mailandpopup.sh bin/README 2 2 recursive-include po README *.sh *.po *.mo *.pot 3 3 recursive-include man README *.sh *.1 -
pykota/trunk/pykota/tool.py
r1917 r1918 22 22 # 23 23 # $Log$ 24 # Revision 1.140 2004/11/15 19:59:34 jalet 25 # PyKota banners now basically work ! 26 # 24 27 # Revision 1.139 2004/11/15 15:54:03 jalet 25 28 # Continued integration of Matt's patch for banners … … 1221 1224 by the printer. 1222 1225 """ 1223 banner = "" # no banner by default1224 1226 if bannerfileorcommand : 1227 banner = "" # no banner by default 1225 1228 if (os.access(bannerfileorcommand, os.X_OK)) : 1226 1229 self.logdebug("Launching %s to generate a banner." % bannerfileorcommand) 1227 1230 child = popen2.Popen3(bannerfileorcommand, capturestderr=1) 1231 banner = child.fromchild.read() 1228 1232 child.tochild.close() 1229 1233 child.childerr.close() 1230 banner = child.fromchild.read()1231 1234 child.fromchild.close() 1232 1235 status = child.wait() … … 1243 1246 banner = fh.read() 1244 1247 fh.close() 1245 return cStringIO.StringIO(banner) 1248 if banner : 1249 return cStringIO.StringIO(banner) 1246 1250 1247 1251 def startingBanner(self, printername) : -
pykota/trunk/setup.py
r1911 r1918 24 24 # 25 25 # $Log$ 26 # Revision 1.59 2004/11/15 19:59:34 jalet 27 # PyKota banners now basically work ! 28 # 26 29 # Revision 1.58 2004/11/12 23:46:43 jalet 27 30 # Heavy work on pkbanner. Not finished yet though, but mostly works. … … 301 304 url = "http://www.librelogiciel.com/software/", 302 305 packages = [ "pykota", "pykota.storages", "pykota.loggers", "pykota.accounters", "pykota.reporters" ], 303 scripts = [ "bin/ autopykota", "bin/dumpykota", "bin/pkpgcounter", "bin/snmpprinterstatus", "bin/pykosd", "bin/edpykota", "bin/repykota", "bin/warnpykota", "bin/pykotme", "bin/pkprinters", "bin/pkhint" ],306 scripts = [ "bin/pkbanner", "bin/autopykota", "bin/dumpykota", "bin/pkpgcounter", "bin/snmpprinterstatus", "bin/pykosd", "bin/edpykota", "bin/repykota", "bin/warnpykota", "bin/pykotme", "bin/pkprinters", "bin/pkhint" ], 304 307 data_files = data_files)