Show
Ignore:
Timestamp:
01/13/06 21:33:33 (18 years ago)
Author:
jerome
Message:

Fixed a problem with fast printers : PyKota only saw them
as being 'idle' because they already went from 'idle'
to 'printing' to 'idle' again.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/accounters/pjl.py

    r2584 r2615  
    3333ITERATIONDELAY = 1   # 1 Second 
    3434STABILIZATIONDELAY = 3 # We must read three times the same value to consider it to be stable 
     35NOPRINTINGMAXDELAY = 30 # The printer must begin to print within 30 seconds. 
    3536 
    3637# Here's the real thing : 
     
    130131    def waitPrinting(self) : 
    131132        """Waits for printer status being 'printing'.""" 
     133        previousValue = self.parent.getLastPageCounter() 
     134        timebefore = time.time() 
    132135        firstvalue = None 
    133136        while 1: 
     
    147150                        # So we can probably quit being sure it is printing. 
    148151                        self.parent.filter.printInfo("Printer %s is lying to us !!!" % self.parent.filter.PrinterName, "warn") 
     152                        break 
     153                    elif (time.time() - timebefore) > NOPRINTINGMAXDELAY : 
     154                        # More than X seconds without the printer being in 'printing' mode 
     155                        # We can safely assume this won't change 
     156                        if self.printerInternalPageCounter == previousValue : 
     157                            # Here the job won't be printed, because probably 
     158                            # the printer rejected it for some reason. 
     159                            self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn") 
     160                        else :      
     161                            # Here the job has already been entirely printed, and 
     162                            # the printer has already passed from 'idle' to 'printing' to 'idle' again. 
     163                            self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 
    149164                        break 
    150165            self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) 
     
    204219            self.filter = fakeFilter() 
    205220            self.protocolHandler = Handler(self, sys.argv[1]) 
     221             
     222        def getLastPageCounter(self) :     
     223            return 0 
    206224         
    207225    acc = fakeAccounter()