Changeset 3530

Show
Ignore:
Timestamp:
04/16/10 15:49:27 (12 years ago)
Author:
jerome
Message:

Removed gettext marker for debugging messages.
Reworked bse's patch in order to fix #54 with suggestions from mhyclak.
This code is currently UNTESTED.

Location:
pykota/trunk/pykota
Files:
2 modified

Legend:

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

    r3529 r3530  
    157157        """Waits for printer status being 'printing'.""" 
    158158        statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 
     159        increment = 1 
    159160        noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay") 
    160161        if not noprintingmaxdelay : 
     
    166167        while True : 
    167168            self.retrieveSNMPValues() 
     169            waitdelay = statusstabilizationdelay * increment 
     170            error = self.checkIfError(self.printerDetectedErrorState) 
    168171            pstatusAsString = printerStatusValues.get(self.printerStatus) 
     172            dstatusAsString = deviceStatusValues.get(self.deviceStatus) 
    169173            if pstatusAsString in ('printing', 'warmup') : 
    170174                break 
     
    184188                    elif noprintingmaxdelay \ 
    185189                         and ((time.time() - self.timebefore) > noprintingmaxdelay) \ 
    186                          and not self.checkIfError(self.printerDetectedErrorState) : 
     190                         and not error : 
    187191                        # More than X seconds without the printer being in 'printing' mode 
    188192                        # We can safely assume this won't change if printer is now 'idle' 
    189                         dstatusAsString = deviceStatusValues.get(self.deviceStatus) 
    190193                        if (pstatusAsString == 'idle') or \ 
    191194                            ((pstatusAsString == 'other') and \ 
     
    200203                                self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 
    201204                            break 
    202             self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) 
    203             time.sleep(statusstabilizationdelay) 
     205                    if error or (dstatusAsString == "down") : 
     206                        if waitdelay < constants.FIVEMINUTES : 
     207                            increment *= 2 
     208            self.parent.filter.logdebug("Waiting %s seconds for printer %s to be printing..." % (waitdelay, self.parent.filter.PrinterName)) 
     209            time.sleep(waitdelay) 
    204210 
    205211    def waitIdle(self) : 
     
    207213        statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 
    208214        statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops") 
    209         idle_num = idle_flag = 0 
     215        increment = 1 
     216        idle_num = 0 
    210217        while True : 
    211218            self.retrieveSNMPValues() 
     219            waitdelay = statusstabilizationdelay * increment 
     220            error = self.checkIfError(self.printerDetectedErrorState) 
    212221            pstatusAsString = printerStatusValues.get(self.printerStatus) 
    213222            dstatusAsString = deviceStatusValues.get(self.deviceStatus) 
    214             idle_flag = 0 
    215             if (not self.checkIfError(self.printerDetectedErrorState)) \ 
    216                and ((pstatusAsString == 'idle') or \ 
    217                          ((pstatusAsString == 'other') and \ 
    218                           (dstatusAsString == 'running'))) : 
    219                 idle_flag = 1       # Standby / Powersave is considered idle 
     223            idle_flag = False 
     224            if (not error) and ((pstatusAsString == 'idle') or \ 
     225                                    ((pstatusAsString == 'other') and \ 
     226                                         (dstatusAsString == 'running'))) : 
     227                idle_flag = True # Standby / Powersave is considered idle 
     228                increment = 1 # Reset initial stabilization delay 
    220229            if idle_flag : 
    221230                if (self.printerInternalPageCounter is not None) \ 
     
    230239            else : 
    231240                idle_num = 0 
    232             self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName) 
    233             time.sleep(statusstabilizationdelay) 
     241            if error or (dstatusAsString == "down") : 
     242                if waitdelay < constants.FIVEMINUTES : 
     243                    increment *= 2 
     244            self.parent.filter.logdebug("Waiting %s seconds for printer %s's idle status to stabilize..." % (waitdelay, 
     245                                                                                                             self.parent.filter.PrinterName)) 
     246            time.sleep(waitdelay) 
    234247 
    235248    def retrieveInternalPageCounter(self) : 
     
    243256            self.waitIdle() 
    244257        except : 
    245             self.parent.filter.printInfo(_("SNMP querying stage interrupted. Using latest value seen for internal page counter (%s) on printer %s.") % (self.printerInternalPageCounter, self.parent.filter.PrinterName), "warn") 
     258            self.parent.filter.printInfo("SNMP querying stage interrupted. Using latest value seen for internal page counter (%s) on printer %s." % (self.printerInternalPageCounter, self.parent.filter.PrinterName), "warn") 
    246259            raise 
    247260        return self.printerInternalPageCounter 
     
    333346        sys.stderr.write("Usage :  python  %s  printer_ip_address\n" % sys.argv[0]) 
    334347    else : 
    335         def _(msg) : 
    336             return msg 
    337  
    338348        pagecounter = main(sys.argv[1]) 
    339349        print "Internal page counter's value is : %s" % pagecounter 
  • pykota/trunk/pykota/constants.py

    r3489 r3530  
    2525STATUSSTABILIZATIONLOOPS = 5  # number of consecutive times the 'idle' status must be seen before we consider it to be stable 
    2626NOPRINTINGMAXDELAY = 60 # The printer must begin to print within 60 seconds by default. 
     27FIVEMINUTES = 300 # Five minutes : maximum delay between two SNMP queries 
    2728 
    2829def get(application, varname) :