Changeset 2615

Show
Ignore:
Timestamp:
01/13/06 21:33:33 (19 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.

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r2614 r2615  
    2424    - 1.24alpha6 : 
    2525     
     26        - Fixed internal SNMP and PJL handling code for very fast 
     27          printers : PyKota didn't see them going from 'idle' 
     28          to 'printing' to 'idle' again. 
     29           
    2630        - Now waitprinter.sh accepts SNMP version number and  
    2731          community name as arguments, thanks to Brandon 
  • 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()             
  • pykota/trunk/pykota/accounters/snmp.py

    r2584 r2615  
    2525ITERATIONDELAY = 1.5   # 1.5 Second 
    2626STABILIZATIONDELAY = 3 # We must read three times the same value to consider it to be stable 
     27NOPRINTINGMAXDELAY = 30 # The printer must begin to print within 30 seconds. 
    2728 
    2829import sys 
     
    9798        def handleAnswer(self, wholeMsg, notusedhere, req): 
    9899            """Decodes and handles the SNMP answer.""" 
    99             self.parent.filter.logdebug("SNMP message : '%s'" % repr(wholeMsg)) 
     100            self.parent.filter.logdebug("SNMP answer : '%s'" % repr(wholeMsg)) 
    100101            ver = alpha.protoVersions[alpha.protoVersionId1] 
    101102            rsp = ver.Message() 
     
    118119                            self.printerStatus = self.values[1] 
    119120                            self.deviceStatus = self.values[2] 
    120                             self.parent.filter.logdebug("SNMP answer is decoded : PageCounter : %s  PrinterStatus : %s  DeviceStatus : %s" % tuple(self.values)) 
     121                            self.parent.filter.logdebug("SNMP answer decoded : PageCounter : %s  PrinterStatus : '%s'  DeviceStatus : '%s'" \ 
     122                                 % (self.printerInternalPageCounter, \ 
     123                                    printerStatusValues.get(self.printerStatus, "ILLEGAL VALUE"), \ 
     124                                    deviceStatusValues.get(self.deviceStatus, "ILLEGAL VALUE"))) 
    121125                        except IndexError :     
    122126                            self.parent.filter.logdebug("SNMP answer is incomplete : %s" % str(self.values)) 
     
    127131        def waitPrinting(self) : 
    128132            """Waits for printer status being 'printing'.""" 
     133            previousValue = self.parent.getLastPageCounter() 
     134            timebefore = time.time() 
    129135            firstvalue = None 
    130136            while 1: 
     
    145151                            # So we can probably quit being sure it is printing. 
    146152                            self.parent.filter.printInfo("Printer %s is lying to us !!!" % self.parent.filter.PrinterName, "warn") 
     153                            break 
     154                        elif (time.time() - timebefore) > NOPRINTINGMAXDELAY : 
     155                            # More than X seconds without the printer being in 'printing' mode 
     156                            # We can safely assume this won't change 
     157                            if self.printerInternalPageCounter == previousValue : 
     158                                # Here the job won't be printed, because probably 
     159                                # the printer rejected it for some reason. 
     160                                self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn") 
     161                            else :      
     162                                # Here the job has already been entirely printed, and 
     163                                # the printer has already passed from 'idle' to 'printing' to 'idle' again. 
     164                                self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 
    147165                            break 
    148166                self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName)     
     
    206224            self.filter = fakeFilter() 
    207225            self.protocolHandler = Handler(self, hostname) 
     226             
     227        def getLastPageCounter(self) :     
     228            return 0 
    208229         
    209230    acc = fakeAccounter()