ProgressReporter(report='stderr', period=10.0, first_report=-1.0)¶
Standard text and graphical progress reports
Initialised with arguments:
Can be one of the following strings:
- Reports progress to standard console.
- Reports progress to error console.
- A simple graphical progress bar using Tkinter.
Alternatively, it can be any output stream in which case text reports will be sent to it, or a custom callback function
report(elapsed, complete)taking arguments
elapsedthe amount of time that has passed and
completethe fraction of the computation finished.
- How often reports should be generated in seconds.
- The time of the first report (nothing will be done before this amount of time has elapsed).
Call at the beginning of a task to start timing it.
Call at the end of a task to finish timing it. Note that with the Tkinter class, if you do not call this it will stop the Python script from finishing, stopping memory from being freed up.
Call with the fraction of the task (or subtask if
subtask()has been called) completed, between 0 and 1.
subtask(complete, tasksize), subsequent calls to update will report progress between a fraction
complete+tasksizeof the total task.
completerepresents the amount of the total task completed at the beginning of the task, and
tasksizethe size of the subtask as a proportion of the whole task.
If a task can be divided into
numtasksequally sized subtasks, you can use this method instead of
tasknumis the number of the subtask about to start.
with ProgressReporter(period=0.1) as progress: for i in xrange(10): time.sleep(1) progress.update((i+1.0)/10)