Messaging

messaging.py

class messaging.MessageHandler(messages, logger=None)

Convenience class for handling messaging.

Includes a concept of progress, which is a measure of number of completed major and minor steps.

For example, when processing a series of map services and their layers, the number of map services is the number of major steps, and the number of layers is the number of minor steps (represents loop-within-loop hierarchy).

setMajorSteps(major_steps)

Set the number of major steps to measure progress against.

Parameters:major_steps – number of major steps of operation
setMinorSteps(minor_steps)

OPTIONAL: Set the number of minor steps to measure progress against.

Parameters:minor_steps – number of major steps of operation
incrementMajorStep()

Increment the current major step by one, and emit a new progress message.

incrementMinorStep()

Increment the current minor step by one, and emit a new progress message.

setProgress(progress)

Emit a new progress message: PROGRESS [PERCENT_COMPLETE]

Parameters:progress – the current progress, on a percent scale.
addMessage(message)

Emit a new message to both messages and logger (if available)

Parameters:message – the message to emit