Changeset 1606 for pykota/trunk/bin
- Timestamp:
- 07/21/04 00:19:45 (20 years ago)
- Location:
- pykota/trunk/bin
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1600 r1606 24 24 # 25 25 # $Log$ 26 # Revision 1.68 2004/07/20 22:19:44 jalet 27 # Sanitized a bit + use of gettext 28 # 26 29 # Revision 1.67 2004/07/16 12:22:45 jalet 27 30 # LPRng support early version … … 348 351 pagelog.close() 349 352 if matchingline is None : 350 self.logdebug("No matching line found in page_log")353 self.logdebug("No matching line found in %s" % pagelogpath) 351 354 return # correct line not found, job-originating-hostname unknown 352 355 else : … … 376 379 self.softwareJobSize = self.precomputeJobSize() 377 380 self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize) 378 self. sendBackChannelData("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice))381 self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 379 382 os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize) 380 383 os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice) 381 382 # checks the user's quota383 action = self.warnUserPQuota(userpquota)384 384 385 385 # if no data to pass to real backend, probably a filter … … 389 389 self.printInfo(_("Job contains no data. Printing is denied."), "warn") 390 390 action = "DENY" 391 else : 392 # checks the user's quota 393 action = self.warnUserPQuota(userpquota) 391 394 392 395 # exports some new environment variables … … 396 399 self.prehook(userpquota) 397 400 398 self. sendBackChannelData("Job accounting begins.")401 self.printInfo(_("Job accounting begins.")) 399 402 self.accounter.beginJob(userpquota) 400 403 else : … … 417 420 # stops accounting. 418 421 self.accounter.endJob(userpquota) 419 self. sendBackChannelData("Job accounting ends.")422 self.printInfo(_("Job accounting ends.")) 420 423 421 424 # retrieve the job size 422 425 if action == "DENY" : 423 426 jobsize = 0 424 self. sendBackChannelData("Job size forced to 0 because printing is denied.")427 self.printInfo(_("Job size forced to 0 because printing is denied.")) 425 428 else : 426 429 jobsize = self.accounter.getJobSize() 427 self. sendBackChannelData("Job size : %i"% jobsize)430 self.printInfo(_("Job size : %i") % jobsize) 428 431 429 432 # update the quota for the current user on this printer 430 self. sendBackChannelData("Updating user %s's quota on printer %s"% (user.Name, printer.Name))433 self.printInfo(_("Updating user %s's quota on printer %s") % (user.Name, printer.Name)) 431 434 jobprice = userpquota.increasePagesUsage(jobsize) 432 435 433 436 # adds the current job to history 434 437 printer.addJobToHistory(self.jobid, user, self.accounter.getLastPageCounter(), action, jobsize, jobprice, self.preserveinputfile, self.title, self.copies, self.options, clienthost, self.jobSizeBytes) 435 self. sendBackChannelData("Job added to history.")438 self.printInfo(_("Job added to history.")) 436 439 437 440 # exports some new environment variables … … 481 484 482 485 # And launch it 483 self. sendBackChannelData("Starting real backend %s with args %s" % (realbackend, " ".join(['"%s"' % a for a in ([os.environ["DEVICE_URI"]] + sys.argv[1:])])))486 self.logdebug("Starting real backend %s with args %s" % (realbackend, " ".join(['"%s"' % a for a in ([os.environ["DEVICE_URI"]] + sys.argv[1:])]))) 484 487 subprocess = PyKotaPopen4([realbackend] + sys.argv[1:], bufsize=0, arg0=os.environ["DEVICE_URI"]) 485 488 … … 511 514 # job's data is in a file, no need to pass the data 512 515 # to the real backend 513 self. sendBackChannelData("Job's data is in %s" % self.preserveinputfile)516 self.logdebug("Job's data is in %s" % self.preserveinputfile) 514 517 infno = None 515 518 endinput = 1 516 519 517 self. sendBackChannelData("Entering streams polling loop...")520 self.logdebug("Entering streams polling loop...") 518 521 MEGABYTE = 1024*1024 519 522 killed = 0 … … 531 534 self.logdebug("Error while sending signal to pid %s : %s" % (subprocess.pid, msg)) 532 535 else : 533 self. sendBackChannelData(_("SIGTERM was sent to real backend %s (pid: %s)") % (realbackend, subprocess.pid))536 self.printInfo(_("SIGTERM was sent to real backend %s (pid: %s)") % (realbackend, subprocess.pid)) 534 537 killed = 1 535 538 … … 541 544 availablefds = [] 542 545 if not availablefds : 543 self. sendBackChannelData("Nothing to do, sleeping a bit...")546 self.logdebug("Nothing to do, sleeping a bit...") 544 547 time.sleep(0.01) # give some time to the system 545 548 else : … … 558 561 indata = "" 559 562 else : 560 self. sendBackChannelData("No data to send to real backend yet, sleeping a bit...")563 self.logdebug("No data to send to real backend yet, sleeping a bit...") 561 564 time.sleep(0.01) 562 565 563 566 if endinput : 564 567 self.unregisterFileNo(pollster, tocfno) 565 self. sendBackChannelData("Closing real backend's stdin.")568 self.logdebug("Closing real backend's stdin.") 566 569 os.close(tocfno) 567 570 inputclosed = 1 … … 595 598 if not data : # If yes, then no more input data 596 599 self.unregisterFileNo(pollster, infno) 597 self. sendBackChannelData("Input data ends.")600 self.logdebug("Input data ends.") 598 601 endinput = 1 # this happens with real files. 599 602 else : … … 601 604 elif fd == fromcfno : 602 605 if not data : 603 self. sendBackChannelData("No back channel data to read from real backend yet, sleeping a bit...")606 self.logdebug("No back channel data to read from real backend yet, sleeping a bit...") 604 607 time.sleep(0.01) 605 608 else : … … 616 619 # Here we are in the case where the input file is stdin. 617 620 # which has no more data to be read. 618 self. sendBackChannelData("Input data ends.")621 self.logdebug("Input data ends.") 619 622 endinput = 1 620 623 elif fd == fromcfno : 621 624 # We are no more interested in this file descriptor 622 self. sendBackChannelData("Closing real backend's stdout+stderr.")625 self.logdebug("Closing real backend's stdout+stderr.") 623 626 os.close(fromcfno) 624 627 endoutput = 1 … … 628 631 629 632 if mask & select.POLLNVAL : 630 self. sendBackChannelData("File %s was closed. Unregistering from polling object." % fd)633 self.logdebug("File %s was closed. Unregistering from polling object." % fd) 631 634 self.unregisterFileNo(pollster, fd) 632 635 except IOError, msg : … … 635 638 # We must close the real backend's input stream 636 639 if killed and not inputclosed : 637 self. sendBackChannelData("Forcing close of real backend's stdin.")640 self.logdebug("Forcing close of real backend's stdin.") 638 641 os.close(tocfno) 639 642 640 self. sendBackChannelData("Exiting streams polling loop...")643 self.logdebug("Exiting streams polling loop...") 641 644 642 645 # Check exit code of original CUPS backend. … … 644 647 # we exited the loop before the real backend exited 645 648 # now we have to wait for it to finish and get its status 646 self. sendBackChannelData("Waiting for real backend to exit...")649 self.logdebug("Waiting for real backend to exit...") 647 650 try : 648 651 status = subprocess.wait() … … 652 655 retcode = os.WEXITSTATUS(status) 653 656 elif not killed : 654 self. printInfo(_("CUPS backend %s died abnormally.") % realbackend, "error")657 self.sendBackChannelData(_("CUPS backend %s died abnormally.") % realbackend, "error") 655 658 retcode = -1 656 659 else : -
pykota/trunk/bin/pkhint
r1584 r1606 24 24 # 25 25 # $Log$ 26 # Revision 1.15 2004/07/20 22:19:45 jalet 27 # Sanitized a bit + use of gettext 28 # 26 29 # Revision 1.14 2004/07/01 19:56:40 jalet 27 30 # Better dispatching of error messages … … 196 199 (backend, destination) = device.split(":", 1) 197 200 except ValueError : 198 raise PyKotaToolError, "Invalid DEVICE_URI : %s\n"% device201 raise PyKotaToolError, _("Invalid DeviceURI : %s") % device 199 202 while destination.startswith("/") : 200 203 destination = destination[1:] … … 220 223 """Main work is done here.""" 221 224 sys.stderr.write("BEWARE : This tool doesn't support LPRng's printcap files yet.\n") 222 print "\nPlease wait while pkhint analyzes your printing system's configuration..."225 print _("\nPlease wait while pkhint analyzes your printing system's configuration...") 223 226 printers = self.extractPrintersInformation() 224 227 devicestypes = self.extractDevices() # TODO : IT'S CUPS ONLY FOR NOW … … 254 257 print "\nSorry, pkhint can't help you for now. Please configure PyKota manually." 255 258 else : 256 print "\nPut the following lines into your /etc/pykota/pykota.conf file :\n"257 print "# BEWARE : if software accounting is suggested, this doesn't mean"258 print "# that hardware accounting wouldn't work, this only means that PyKota"259 print "# wasn't able to autodetect which hardware accounting method to use."259 print _("\nPut the following lines into your /etc/pykota/pykota.conf file :\n") 260 print _("# BEWARE : if software accounting is suggested, this doesn't mean") 261 print _("# that hardware accounting wouldn't work, this only means that PyKota") 262 print _("# wasn't able to autodetect which hardware accounting method to use.") 260 263 for (printer, accounter) in configuration : 261 264 print "[%s]" % printer -
pykota/trunk/bin/pykosd
r1605 r1606 24 24 # 25 25 # $Log$ 26 # Revision 1.5 2004/07/20 22:19:45 jalet 27 # Sanitized a bit + use of gettext 28 # 26 29 # Revision 1.4 2004/07/19 22:37:13 jalet 27 30 # pykosd is now a very good tool … … 101 104 duration = int(options["duration"]) 102 105 except : 103 raise PyKotaToolError, "Invalid duration option %s"% str(options["duration"])106 raise PyKotaToolError, _("Invalid duration option %s") % str(options["duration"]) 104 107 105 108 try : 106 109 loop = int(options["loop"]) 107 110 except : 108 raise PyKotaToolError, "Invalid loop option %s"% str(options["loop"])111 raise PyKotaToolError, _("Invalid loop option %s") % str(options["loop"]) 109 112 110 113 try : 111 114 sleep = float(options["sleep"]) 112 115 except : 113 raise PyKotaToolError, "Invalid sleep option %s"% str(options["sleep"])116 raise PyKotaToolError, _("Invalid sleep option %s") % str(options["sleep"]) 114 117 115 118 uid = os.geteuid() … … 118 121 user = cmd.storage.getUserFromBackend(uname) # don't use cache 119 122 if not user.Exists : 120 raise PyKotaToolError, "User %s doesn't exist in PyKota's database."% uname123 raise PyKotaToolError, _("User %s doesn't exist in PyKota's database") % uname 121 124 if user.LimitBy == "quota" : 122 125 printers = cmd.storage.getMatchingPrinters("*")