Changeset 2895
- Timestamp:
- 05/23/06 23:28:39 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2891 r2895 371 371 self.logdebug("Job's attributes sanitizing done.") 372 372 373 def didUserConfirm(self) : 374 """Asks for user confirmation through an external script. 375 376 returns False if the end user wants to cancel the job, else True. 377 """ 378 self.logdebug("Checking if we have to ask for user's confirmation...") 379 answer = None 380 confirmationcommand = self.config.getAskConfirmation(self.PrinterName) 381 if confirmationcommand : 382 self.logdebug("Launching subprocess [%s] to ask for user confirmation." \ 383 % confirmationcommand) 384 inputfile = os.popen(confirmationcommand, "r") 385 try : 386 for answer in inputfile.xreadlines() : 387 answer = answer.strip().upper() 388 if answer == "CANCEL" : 389 break 390 except IOError, msg : 391 self.logdebug("IOError while reading subprocess' output : %s" % msg) 392 inputfile.close() 393 self.logdebug("User's confirmation received : %s" % (((answer == "CANCEL") and "CANCEL") or "CONTINUE")) 394 else : 395 self.logdebug("No need to ask for user's confirmation, job processing will continue.") 396 return (answer != "CANCEL") 397 373 398 def overwriteJobTicket(self) : 374 399 """Should we overwrite the job's ticket (username and billingcode) ?""" 375 400 self.logdebug("Checking if we need to overwrite the job ticket...") 376 401 jobticketcommand = self.config.getOverwriteJobTicket(self.PrinterName) 377 if jobticketcommand is not None:402 if jobticketcommand : 378 403 username = billingcode = action = None 379 404 self.logdebug("Launching subprocess [%s] to overwrite the job ticket." \ … … 1020 1045 1021 1046 if self.Action not in ("DENY", "CANCEL") : 1047 if not self.didUserConfirm() : 1048 self.Action = "CANCEL" 1049 self.Reason = _("Print job cancelled.") 1050 os.environ["PYKOTASTATUS"] = "CANCELLED" 1051 1052 if self.Action not in ("DENY", "CANCEL") : 1022 1053 if self.Printer.MaxJobSize and (self.softwareJobSize > self.Printer.MaxJobSize) : 1023 1054 # This printer was set to refuse jobs this large. -
pykota/trunk/conf/pykota.conf.sample
r2884 r2895 459 459 # CANCEL 460 460 # 461 # NB : the output is entirely read, and the latest value462 # seen is used, so you command can output several usernames461 # NB : the output of your command is entirely read, and the latest 462 # value seen is used, so you command can output several usernames 463 463 # or billing codes and only the latest ones will be used. 464 464 # If only USERNAME= lines are printed, the billing code, … … 475 475 # overwrite_jobticket : /usr/bin/pknotify --destination $PYKOTAJOBORIGINATINGHOSTNAME:7654 --timeout 180 --denyafter 3 --checkauth --ask "Username:username:$PYKOTAUSERNAME" "Password:password:" 476 476 # overwrite_jobticket : /path/to/some/script/or/command 477 478 479 480 # Should we ask the end user for a confirmation about their print job ? 481 # 482 # Any script can be launched here. If your script prints CANCEL on 483 # its standard output, the job is cancelled, else processing of the 484 # job continues to next step. 485 # 486 # NB : the output of your command is read until CANCEL is found 487 # or all lines have been read. 488 # 489 # This value can be set either globally or on a per printer basis 490 # If both are defined, the printer option has priority. 491 # 492 # examples : 493 # 494 # askconfirmation : /usr/bin/pknotify --destination $PYKOTAJOBORIGINATINGHOSTNAME:7654 --timeout 120 --confirm "Hello $PYKOTAUSERNAME.\nPrint job $PYKOTAJOBID send to printer $PYKOTAPRINTERNAME is $PYKOTAPRECOMPUTEDJOBSIZE pages long\nand will cost you $PYKOTAPRECOMPUTEDJOBPRICE credits.\n\nYou currently have $PYKOTABALANCE credits.\n\nDo you really want to print ?" 477 495 478 496 -
pykota/trunk/NEWS
r2891 r2895 24 24 - 1.25alpha4 (2006-05-22) : 25 25 26 - Introduced the 'askconfirmation' directive to interact with 27 the end user through any script (pknotify is recommended) 28 and see if he really wants to print when knowing the cost 29 of the job. 30 26 31 - Now uses pkipplib if present to directly retrieve the job 27 32 information from the CUPS server over IPP. -
pykota/trunk/pykota/config.py
r2759 r2895 249 249 return # No prefix to strip off 250 250 251 def getAskConfirmation(self, printername) : 252 """Returns the askconfirmation directive's content, or None if unset.""" 253 try : 254 return self.getPrinterOption(printername, "askconfirmation").strip() 255 except PyKotaConfigError : 256 return # No overwriting will be done 257 251 258 def getOverwriteJobTicket(self, printername) : 252 259 """Returns the overwrite_jobticket directive's content, or None if unset."""