Changeset 2617

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

Fix for the fix : we only exit loop after 30 seconds if printer is idle,
not if unreachable or in error.

Files:
1 modified

Legend:

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

    r2615 r2617  
    121121                            self.parent.filter.logdebug("SNMP answer decoded : PageCounter : %s  PrinterStatus : '%s'  DeviceStatus : '%s'" \ 
    122122                                 % (self.printerInternalPageCounter, \ 
    123                                     printerStatusValues.get(self.printerStatus, "ILLEGAL VALUE"), \ 
    124                                     deviceStatusValues.get(self.deviceStatus, "ILLEGAL VALUE"))) 
     123                                    printerStatusValues.get(self.printerStatus), \ 
     124                                    deviceStatusValues.get(self.deviceStatus))) 
    125125                        except IndexError :     
    126126                            self.parent.filter.logdebug("SNMP answer is incomplete : %s" % str(self.values)) 
     
    154154                        elif (time.time() - timebefore) > NOPRINTINGMAXDELAY : 
    155155                            # 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") 
    165                             break 
     156                            # We can safely assume this won't change if printer is now 'idle' 
     157                            pstatusAsString = printerStatusValues.get(self.printerStatus) 
     158                            dstatusAsString = deviceStatusValues.get(self.deviceStatus) 
     159                            if (pstatusAsString == 'idle') or \ 
     160                                ((pstatusAsString == 'other') and \ 
     161                                 (dstatusAsString == 'running')) : 
     162                                if self.printerInternalPageCounter == previousValue : 
     163                                    # Here the job won't be printed, because probably 
     164                                    # the printer rejected it for some reason. 
     165                                    self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn") 
     166                                else :      
     167                                    # Here the job has already been entirely printed, and 
     168                                    # the printer has already passed from 'idle' to 'printing' to 'idle' again. 
     169                                    self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 
     170                                break 
    166171                self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName)     
    167172                time.sleep(ITERATIONDELAY) 
     
    191196        def retrieveInternalPageCounter(self) : 
    192197            """Returns the page counter from the printer via internal SNMP handling.""" 
     198            self.waitPrinting() 
    193199            try : 
    194200                if (os.environ.get("PYKOTASTATUS") != "CANCELLED") and \