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:
objectProvides 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, byReportProgress()in the first scenario andStop()in the second scenario. You can configure the format of the progress messages by settingProgressMessage1,ProgressMessage2, andCompletionMessage. All messages are reported as Informational log messages. You can configure the logging channel that is used to report the messages by settingLoggingChannel.- 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 beforeOperationsCompleted==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
loggingmodule 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
NoneandStart()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 theProgressReporterinstance will automatically call the geoprocessor’sSetProgressorPosition()function whenReportProgress()is called.If this property is
NoneorStart()is called without a total number of operations, theProgressReporterinstance will not manipulate the geoprocessor’s progress bar.Minimum length꞉ 1.
- Returns:
New
ProgressReporterinstance.- Return type:
Properties
- property AbortedMessage
(
str) printf-style format string for reporting that processing was stopped prematurely (i.e. thatStop()was called beforeOperationsCompleted==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
(
strorNone) Label to use for the ArcGIS geoprocessor progressor. Read only. Minimum length꞉ 1. If this property is notNoneandStart()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 theProgressReporterinstance will automatically call the geoprocessor’sSetProgressorPosition()function whenReportProgress()is called.If this property is
NoneorStart()is called without a total number of operations, theProgressReporterinstance 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 toReportProgress()orStop()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 Pythonloggingmodule 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 whenReportProgress()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
(
datetimeorNone) The time processing was completed. Read only. This property is set to the current system time whenReportProgress()is called for the last iteration (when the total number of iterations is known a priori) or whenStop()is called (when the the total number of iterations is not known a priori), using thedatetime.datetime.now()method.
- property TimeElapsed
(
timedeltaorNone) The time elapsed since processing was started, orNoneif processing has not started yet. Read only. Processing starts whenStart()is called and stops whenReportProgress()is called for the last iteration (when the total number of iterations is known a priori) or whenStop()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
(
datetimeorNone) The time processing was started. Read only. This property is set to the current system time whenStart()is called, using thedatetime.datetime.now()method.
- property TotalOperations
(
intorNone) Total number of iterations in this iterative operation, orNoneif the number of iterations is not known a priori. This property is initialized by theStart()method.
Methods
Signals the
ProgressReporterthat another one or more iterations just completed.Signals the
ProgressReporterthat processing has started.Signals the ProgressReporter that processing is complete.