Ejemplo n.º 1
0
 def waitIdle(self) :
     """Waits for printer status being 'idle'."""
     statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
     statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops")
     idle_num = idle_flag = 0
     while 1 :
         self.retrieveSNMPValues()
         pstatusAsString = printerStatusValues.get(self.printerStatus)
         dstatusAsString = deviceStatusValues.get(self.deviceStatus)
         idle_flag = 0
         if (not self.checkIfError(self.printerDetectedErrorState)) \
            and ((pstatusAsString == 'idle') or \
                      ((pstatusAsString == 'other') and \
                       (dstatusAsString == 'running'))) :
             idle_flag = 1       # Standby / Powersave is considered idle
         if idle_flag :    
             if (self.printerInternalPageCounter is not None) \
                and self.skipinitialwait \
                and (os.environ.get("PYKOTAPHASE") == "BEFORE") :
                 self.parent.filter.logdebug("No need to wait for the printer to be idle, it is the case already.")
                 return 
             idle_num += 1
             if idle_num >= statusstabilizationloops :
                 # printer status is stable, we can exit
                 break
         else :    
             idle_num = 0
         self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName)    
         time.sleep(statusstabilizationdelay)
Ejemplo n.º 2
0
 def waitIdle(self):
     """Waits for printer status being 'idle'."""
     statusstabilizationdelay = constants.get(self.parent.filter,
                                              "StatusStabilizationDelay")
     statusstabilizationloops = constants.get(self.parent.filter,
                                              "StatusStabilizationLoops")
     idle_num = 0
     while True:
         self.retrievePJLValues()
         if self.printerStatus in ('10000', '10001', '35078', '40000'):
             if (self.printerInternalPageCounter is not None) \
                and self.skipinitialwait \
                and (os.environ.get("PYKOTAPHASE") == "BEFORE") :
                 self.parent.filter.logdebug(
                     "No need to wait for the printer to be idle, it is the case already."
                 )
                 return
             idle_num += 1
             if idle_num >= statusstabilizationloops:
                 # printer status is stable, we can exit
                 break
         else:
             idle_num = 0
         self.parent.filter.logdebug(
             _("Waiting for printer %s's idle status to stabilize...") %
             self.parent.filter.PrinterName)
         time.sleep(statusstabilizationdelay)
Ejemplo n.º 3
0
 def waitPrinting(self):
     """Waits for printer status being 'printing'."""
     statusstabilizationdelay = constants.get(self.parent.filter,
                                              "StatusStabilizationDelay")
     noprintingmaxdelay = constants.get(self.parent.filter,
                                        "NoPrintingMaxDelay")
     if not noprintingmaxdelay:
         self.parent.filter.logdebug(
             "Will wait indefinitely until printer %s is in 'printing' state."
             % self.parent.filter.PrinterName)
     else:
         self.parent.filter.logdebug(
             "Will wait until printer %s is in 'printing' state or %i seconds have elapsed."
             % (self.parent.filter.PrinterName, noprintingmaxdelay))
     previousValue = self.parent.getLastPageCounter()
     timebefore = time.time()
     firstvalue = None
     while True:
         self.retrievePJLValues()
         if self.printerStatus in ('10023', '10003'):
             break
         if self.printerInternalPageCounter is not None:
             if firstvalue is None:
                 # first time we retrieved a page counter, save it
                 firstvalue = self.printerInternalPageCounter
             else:
                 # second time (or later)
                 if firstvalue < self.printerInternalPageCounter:
                     # Here we have a printer which lies :
                     # it says it is not printing or warming up
                     # BUT the page counter increases !!!
                     # So we can probably quit being sure it is printing.
                     self.parent.filter.printInfo(
                         "Printer %s is lying to us !!!" %
                         self.parent.filter.PrinterName, "warn")
                     break
                 elif noprintingmaxdelay and (
                     (time.time() - timebefore) > noprintingmaxdelay):
                     # More than X seconds without the printer being in 'printing' mode
                     # We can safely assume this won't change if printer is now 'idle'
                     if self.printerStatus in ('10000', '10001', '35078',
                                               '40000'):
                         if self.printerInternalPageCounter == previousValue:
                             # Here the job won't be printed, because probably
                             # the printer rejected it for some reason.
                             self.parent.filter.printInfo(
                                 "Printer %s probably won't print this job !!!"
                                 % self.parent.filter.PrinterName, "warn")
                         else:
                             # Here the job has already been entirely printed, and
                             # the printer has already passed from 'idle' to 'printing' to 'idle' again.
                             self.parent.filter.printInfo(
                                 "Printer %s has probably already printed this job !!!"
                                 % self.parent.filter.PrinterName, "warn")
                         break
         self.parent.filter.logdebug(
             _("Waiting for printer %s to be printing...") %
             self.parent.filter.PrinterName)
         time.sleep(statusstabilizationdelay)
Ejemplo n.º 4
0
 def waitPrinting(self) :
     """Waits for printer status being 'printing'."""
     statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
     noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay")
     if not noprintingmaxdelay :
         self.parent.filter.logdebug("Will wait indefinitely until printer %s is in 'printing' state." % self.parent.filter.PrinterName)
     else :
         self.parent.filter.logdebug("Will wait until printer %s is in 'printing' state or %i seconds have elapsed." % (self.parent.filter.PrinterName, noprintingmaxdelay))
     previousValue = self.parent.getLastPageCounter()
     firstvalue = None
     increment = 1
     waitdelay = statusstabilizationdelay * increment
     while True :
         self.retrieveSNMPValues()
         error = self.checkIfError(self.printerDetectedErrorState)
         pstatusAsString = printerStatusValues.get(self.printerStatus)
         dstatusAsString = deviceStatusValues.get(self.deviceStatus)
         if pstatusAsString in ('printing', 'warmup') :
             break
         if self.printerInternalPageCounter is not None :
             if firstvalue is None :
                 # first time we retrieved a page counter, save it
                 firstvalue = self.printerInternalPageCounter
             else :
                 # second time (or later)
                 if firstvalue < self.printerInternalPageCounter :
                     # Here we have a printer which lies :
                     # it says it is not printing or warming up
                     # BUT the page counter increases !!!
                     # So we can probably quit being sure it is printing.
                     self.parent.filter.printInfo("Printer %s is lying to us !!!" % self.parent.filter.PrinterName, "warn")
                     break
                 elif noprintingmaxdelay \
                      and ((time.time() - self.timebefore) > noprintingmaxdelay) \
                      and not error :
                     # More than X seconds without the printer being in 'printing' mode
                     # We can safely assume this won't change if printer is now 'idle'
                     if (pstatusAsString == 'idle') or \
                         ((pstatusAsString == 'other') and \
                          (dstatusAsString in ('running', 'warning'))) :
                         if self.printerInternalPageCounter == previousValue :
                             # Here the job won't be printed, because probably
                             # the printer rejected it for some reason.
                             self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn")
                         else :
                             # Here the job has already been entirely printed, and
                             # the printer has already passed from 'idle' to 'printing' to 'idle' again.
                             self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn")
                         break
                 if error or (dstatusAsString == "down") :
                     if waitdelay < constants.FIVEMINUTES :
                         increment *= 2
                 else :
                     increment = 1
         self.parent.filter.logdebug("Waiting %s seconds for printer %s to be printing..." % (waitdelay,
                                                                                              self.parent.filter.PrinterName))
         time.sleep(waitdelay)
         waitdelay = statusstabilizationdelay * increment
Ejemplo n.º 5
0
 def waitPrinting(self) :
     """Waits for printer status being 'printing'."""
     statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
     noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay")
     if not noprintingmaxdelay :
         self.parent.filter.logdebug("Will wait indefinitely until printer %s is in 'printing' state." % self.parent.filter.PrinterName)
     else :    
         self.parent.filter.logdebug("Will wait until printer %s is in 'printing' state or %i seconds have elapsed." % (self.parent.filter.PrinterName, noprintingmaxdelay))
     previousValue = self.parent.getLastPageCounter()
     timebefore = time.time()
     firstvalue = None
     while True :
         self.retrievePJLValues()
         if self.printerStatus in ('10023', '10003') :
             break
         if self.printerInternalPageCounter is not None :    
             if firstvalue is None :
                 # first time we retrieved a page counter, save it
                 firstvalue = self.printerInternalPageCounter
             else :     
                 # second time (or later)
                 if firstvalue < self.printerInternalPageCounter :
                     # Here we have a printer which lies :
                     # it says it is not printing or warming up
                     # BUT the page counter increases !!!
                     # So we can probably quit being sure it is printing.
                     self.parent.filter.printInfo("Printer %s is lying to us !!!" % self.parent.filter.PrinterName, "warn")
                     break
                 elif noprintingmaxdelay and ((time.time() - timebefore) > noprintingmaxdelay) :
                     # More than X seconds without the printer being in 'printing' mode
                     # We can safely assume this won't change if printer is now 'idle'
                     if self.printerStatus in ('10000', '10001', '35078', '40000') :
                         if self.printerInternalPageCounter == previousValue :
                             # Here the job won't be printed, because probably
                             # the printer rejected it for some reason.
                             self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn")
                         else :     
                             # Here the job has already been entirely printed, and
                             # the printer has already passed from 'idle' to 'printing' to 'idle' again.
                             self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn")
                         break
         self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName)
         time.sleep(statusstabilizationdelay)
Ejemplo n.º 6
0
 def waitIdle(self) :
     """Waits for printer status being 'idle'."""
     statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
     statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops")
     idle_num = 0
     while True :
         self.retrievePJLValues()
         if self.printerStatus in ('10000', '10001', '35078', '40000') :
             if (self.printerInternalPageCounter is not None) \
                and self.skipinitialwait \
                and (os.environ.get("PYKOTAPHASE") == "BEFORE") :
                 self.parent.filter.logdebug("No need to wait for the printer to be idle, it is the case already.")
                 return 
             idle_num += 1
             if idle_num >= statusstabilizationloops :
                 # printer status is stable, we can exit
                 break
         else :    
             idle_num = 0
         self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName)
         time.sleep(statusstabilizationdelay)
Ejemplo n.º 7
0
 def waitIdle(self) :
     """Waits for printer status being 'idle'."""
     statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
     statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops")
     increment = 1
     waitdelay = statusstabilizationdelay * increment
     idle_num = 0
     while True :
         self.retrieveSNMPValues()
         error = self.checkIfError(self.printerDetectedErrorState)
         pstatusAsString = printerStatusValues.get(self.printerStatus)
         dstatusAsString = deviceStatusValues.get(self.deviceStatus)
         idle_flag = False
         if (not error) and ((pstatusAsString == 'idle') or \
                                 ((pstatusAsString == 'other') and \
                                      (dstatusAsString in ('running', 'warning')))) :
             idle_flag = True # Standby / Powersave is considered idle
             increment = 1 # Reset initial stabilization delay
         if idle_flag :
             if (self.printerInternalPageCounter is not None) \
                and self.skipinitialwait \
                and (os.environ.get("PYKOTAPHASE") == "BEFORE") :
                 self.parent.filter.logdebug("No need to wait for the printer to be idle, it is the case already.")
                 return
             idle_num += 1
             if idle_num >= statusstabilizationloops :
                 # printer status is stable, we can exit
                 break
         else :
             idle_num = 0
         if error or (dstatusAsString == "down") :
             if waitdelay < constants.FIVEMINUTES :
                 increment *= 2
         else :
             increment = 1
         self.parent.filter.logdebug("Waiting %s seconds for printer %s's idle status to stabilize..." % (waitdelay,
                                                                                                          self.parent.filter.PrinterName))
         time.sleep(waitdelay)
         waitdelay = statusstabilizationdelay * increment