Package wsatools :: Module Logger :: Class ForLoopMonitor
[hide private]

Class ForLoopMonitor

source code


Monitors lengthy For-Loops by logging progress at 10% intervals. (Following an initial 1% interval in case loop is very time consuming). Also displayed at each marker is an estimated time until completion (ETC). Two estimates are provided, one based the overall speed of the loop, the other based on the latest speed of the loop since the last marker.


To Do: Optionally supply separation of markers.

Instance Methods [hide private]
 
__init__(self, aList, minLoops=2, threadID='')
Initialise monitor by passing it the list to be iterated over, so the total number loops can be determined.
source code
 
postMessage(self, msg='')
Log a progress update on demand; at end of loop-body.
source code
 
preMessage(self, msg='', offset=0)
Log a progress update on demand; at start of loop-body.
source code
 
testForOutput(self, msg='')
Log progress update when sufficient progress is made.
source code
bool
_atNextMarker(self, percent)
Returns: True if progress is sufficient to warrant logging a progress update message
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  markers = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
List of progress display markers - 1% then every 10%.
  _end = 0
Total number of loops required.
  _isLogged = True
Progress through for-loop should be logged?
  _isOnDemand = False
Return progress on demand?
  _lastPercent = 0.0
Percentage complete at last time marker.
  _lastTime = 0.0
Time at last marker.
  _marked = {1: False, 10: False, 20: False, 30: False, 40: Fals...
Dictionary of flags denoting which markers have been passed.
  _progress = 0
Current loop number.
  _startTime = 0.0
Time at which for-loop began.
  _threadID = ''
Identification string for this thread.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, aList, minLoops=2, threadID='')
(Constructor)

source code 

Initialise monitor by passing it the list to be iterated over, so the total number loops can be determined. This must be called immediately before the start of the loop as timing starts on initialisation.

Parameters:
  • aList (list or int) - Sequence that the For-Loop is looping over; or its length.
  • minLoops (int) - Minimum number of loops for logging of progress.
  • threadID (str) - An ID string to identify current thread.
Overrides: object.__init__

postMessage(self, msg='')

source code 

Log a progress update on demand; at end of loop-body.

Parameters:
  • msg (str) - Display this message first.

preMessage(self, msg='', offset=0)

source code 

Log a progress update on demand; at start of loop-body.

Parameters:
  • msg (str) - Display this message first.
  • offset (int) - Optional positional offset for the X of Y message.

testForOutput(self, msg='')

source code 

Log progress update when sufficient progress is made.

Parameters:
  • msg (str) - Display this message along with a continuous update.

_atNextMarker(self, percent)

source code 
Parameters:
  • percent (float) - Total progress made as a percentage.
Returns: bool
True if progress is sufficient to warrant logging a progress update message

Class Variable Details [hide private]

_marked

Dictionary of flags denoting which markers have been passed.

Value:
{1: False,
 10: False,
 20: False,
 30: False,
 40: False,
 50: False,
 60: False,
 70: False,
...