GeoEco.Logging.ProgressReporter

class GeoEco.Logging.ProgressReporter(progressMessage1='Progress report: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation, %(opsRemaining)i remaining, estimated completion time: %(etc)s.', progressMessage2='Progress report: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation.', completionMessage='Processing complete: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation.', abortedMessage='Processing stopped before all operations were completed: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation, %(opsIncomplete)i operations not completed.', loggingChannel='GeoEco', arcGISProgressorLabel=None)

Bases: object

Provides a simple mechanism to periodically report progress to the user during iterative operations.

This class provides progress-reporting capability for two kinds of iterative operations: those for which the total number of iterations is known when the operation is started, and those for which the total number of iterations cannot be determined. In both cases, this class periodically reports the elapsed time, the number of iterations completed, and the average time per iteration. If the number of iterations is known, this class also reports the number of iterations remaining and the estimated time of completion.

When the total number of iterations is known, use this pattern:

operations = [...]                          # List of operations to perform
progressReporter = ProgressReporter()
progressReporter.Start(len(operations))
for op in operations:
    ...                                     # Do one operation
    progressReporter.ReportProgress()

But when the total number of iterations is not known, use this pattern:

progressReporter = ProgressReporter()
progressReporter.Start()
while True:
    ...                                     # Do one operation or exit loop if done
    progressReporter.ReportProgress()
progressReporter.Stop()

ReportProgress() will report the first message after one minute and an additional message every five minutes thereafter. A message will also be reported when processing is complete, by ReportProgress() in the first scenario and Stop() in the second scenario. You can configure the format of the progress messages by setting ProgressMessage1, ProgressMessage2, and CompletionMessage. All messages are reported as Informational log messages. You can configure the logging channel that is used to report the messages by setting LoggingChannel.

Parameters:
  • progressMessage1 (str, optional) –

    printf-style format string for periodically reporting progress when the total number of iterations is known a priori.

    Your string must include all five format specifiers, as in this example:

    'Progress report: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation, %(opsRemaining)i remaining, estimated completion time: %(etc)s.'
    

    Minimum length꞉ 1.

  • progressMessage2 (str, optional) –

    printf-style format string for periodically reporting progress when the total number of iterations is not known a priori.

    Your string must include all three format specifiers, as in this example:

    'Progress report: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation.'
    

    Minimum length꞉ 1.

  • completionMessage (str, optional) –

    printf-style format string for reporting that processing is complete.

    Your string must include all three format specifiers, as in this example:

    'Processing complete: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation.'
    

    Minimum length꞉ 1.

  • abortedMessage (str, optional) –

    printf-style format string for reporting that processing was stopped prematurely (i.e. that Stop() was called before OperationsCompleted == TotalOperations).

    Your string must include all four format specifiers, as in this example:

    'Processing stopped before all operations were completed: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation, %(opsIncomplete)i operations not completed.'
    

    Minimum length꞉ 1.

  • loggingChannel (str, optional) –

    Logging channel that progress messages should be reported to.

    Please see the documentation for the Python logging module for more information about logging channels. All progress messages are reported at the Info logging level. Minimum length꞉ 1.

  • arcGISProgressorLabel (str, optional) –

    Label to use for the ArcGIS geoprocessor progressor.

    If this property is not None and Start() is called with a total number of operations, the value of this property will be used as the progressor label (the text that appears above the progress bar) and the ProgressReporter instance will automatically call the geoprocessor’s SetProgressorPosition() function when ReportProgress() is called.

    If this property is None or Start() is called without a total number of operations, the ProgressReporter instance will not manipulate the geoprocessor’s progress bar. Minimum length꞉ 1.

Returns:

New ProgressReporter instance.

Return type:

ProgressReporter

Properties

property AbortedMessage

(str) printf-style format string for reporting that processing was stopped prematurely (i.e. that Stop() was called before OperationsCompleted == TotalOperations). Minimum length꞉ 1. Your string must include all four format specifiers, as in this example:

'Processing stopped before all operations were completed: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation, %(opsIncomplete)i operations not completed.'
property ArcGISProgressorLabel

(str or None) Label to use for the ArcGIS geoprocessor progressor. Read only. Minimum length꞉ 1. If this property is not None and Start() is called with a total number of operations, the value of this property will be used as the progressor label (the text that appears above the progress bar) and the ProgressReporter instance will automatically call the geoprocessor’s SetProgressorPosition() function when ReportProgress() is called.

If this property is None or Start() is called without a total number of operations, the ProgressReporter instance will not manipulate the geoprocessor’s progress bar.

property CompletionMessage

(str) printf-style format string for reporting that processing is complete. Minimum length꞉ 1. Your string must include all three format specifiers, as in this example:

'Processing complete: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation.'
property HasCompleted

(bool) True if processing has completed (i.e. the last operation was reported to ReportProgress() or Stop() was called). Read only.

property HasStarted

(bool) True if processing has started (i.e. if Start() was called). Read only.

property LoggingChannel

(str) Logging channel that progress messages should be reported to. Minimum length꞉ 1. Please see the documentation for the Python logging module for more information about logging channels. All progress messages are reported at the Info logging level.

property OperationsCompleted

(int) Total number of iterations that have been completed so far. Read only. This property is updated when ReportProgress() is called.

property ProgressMessage1

(str) printf-style format string for periodically reporting progress when the total number of iterations is known a priori. Minimum length꞉ 1. Your string must include all five format specifiers, as in this example:

'Progress report: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation, %(opsRemaining)i remaining, estimated completion time: %(etc)s.'
property ProgressMessage2

(str) printf-style format string for periodically reporting progress when the total number of iterations is not known a priori. Minimum length꞉ 1. Your string must include all three format specifiers, as in this example:

'Progress report: %(elapsed)s elapsed, %(opsCompleted)i operations completed, %(perOp)s per operation.'
property TimeCompleted

(datetime or None) The time processing was completed. Read only. This property is set to the current system time when ReportProgress() is called for the last iteration (when the total number of iterations is known a priori) or when Stop() is called (when the the total number of iterations is not known a priori), using the datetime.datetime.now() method.

property TimeElapsed

(timedelta or None) The time elapsed since processing was started, or None if processing has not started yet. Read only. Processing starts when Start() is called and stops when ReportProgress() is called for the last iteration (when the total number of iterations is known a priori) or when Stop() is called (when the the total number of iterations is not known a priori). After processing has stopped, this property will consistently return the total time required for processing (it will not keep increasing as additional time passes).

property TimeStarted

(datetime or None) The time processing was started. Read only. This property is set to the current system time when Start() is called, using the datetime.datetime.now() method.

property TotalOperations

(int or None) Total number of iterations in this iterative operation, or None if the number of iterations is not known a priori. This property is initialized by the Start() method.

Methods

ReportProgress

Signals the ProgressReporter that another one or more iterations just completed.

Start

Signals the ProgressReporter that processing has started.

Stop

Signals the ProgressReporter that processing is complete.