Functions for Python
The following functions apply to Python agents in both real-time and batch workflows.
This section includes the following:
- 1 UDR Related Functions
- 1.1 udrRoute
- 1.1.1 Example - udrRoute
- 1.2 udrCreate
- 1.2.1 Example - udrCreate
- 1.3 udrIsPresent
- 1.3.1 Example - udrIsPresent
- 1.4 udrUnsetPresent
- 1.5 udrConsume
- 1.1 udrRoute
- 2 Debug Related Functions
- 2.1 debug
- 2.2 isDebugEnabled
- 3 MIM Related Functions
- 3.1 mimGet
- 3.1.1 Example - mimGet
- 3.2 mimSet
- 3.2.1 Example - mimSet
- 3.1 mimGet
- 4 Misc Functions
- 4.1 abort
- 4.1.1 Note!
- 4.1.2 Example - abort
- 4.2 wfStop
- 4.2.1 Example - wfStop
- 4.3 isStopped
- 4.3.1 Note!
- 4.3.2 Example - isStopped
- 4.1 abort
- 5 Dynamic Functions
- 5.1 dynamicFieldGet
- 6 Timeout Functions
- 6.1.1 Note!
- 6.2 setTimeout
- 6.3 removeTimeout
- 7 Log Related Functions
- 7.1 logInformation
- 7.2 logWarning
- 7.3 logError
- 7.4 logException
- 7.4.1 Example - logException
- 7.5 formatException
- 8 Â Functions for Python Agents in Batch Workflows Only
- 8.1 beginBatch
- 8.1.1 Note!
- 8.1.2 Example - beginBatch
- 8.2 endbatch
- 8.2.1 Note!
- 8.3 cancelBatch
- 8.3.1 Example - cancelBatch
- 8.4 splitBatch
- 8.4.1 Note!
- 8.5 hintEndBatch
- 8.6 getTransactionId
- 8.1 beginBatch
UDR Related Functions
udrRoute
This function routes a UDR or bytearray to all the output routes, or a named output route.
def udrRoute(udr, route=None)
Parameter | Description |
---|---|
| The UDR to route |
| The route on which to send the UDR |
Returns | Nothing |
Example - udrRoute
udrCreate
This function creates a new UDR of the specified type, and can take keyword arguments to set its fields.
def udrCreate(typename, **kwargs)
Parameter | Description |
---|---|
| A defined UDR type |
| Keyword arguments to set the specified fields |
Returns | A UDR of the type specified |
Example - udrCreate
udrIsPresent
 This function returns True if the UDR field is present.
def udrIsPresent(udr, attr)
Parameter | Description |
---|---|
| The UDR |
| The attribute name |
Returns | True if the UDR field is present. |
Example - udrIsPresent
udrUnsetPresent
 This function marks an optional attribute for a UDR as not present.
Parameter | Description |
---|---|
| The UDR |
| The attribute name |
Returns | Nothing |
udrConsume
This function consumes a UDR routed to the Python Connector agent. The timeout is in seconds.
Parameter | Description |
---|---|
| The timeout in seconds, which waits forever if no timeout is specified |
Returns | The UDR or bytearray routed, or None if timed out while waiting |
Debug Related Functions
debug
This function prints the supplied object to the output target specified in the Execution tab of the Workflow Properties dialog.Â
If Event is selected, the output is shown in the Workflow Monitor.
Parameter | Description |
---|---|
| The object to write to debug output. The object can be of any type. Note that printing a UDR type will dump all the field values, which may be a large amount of data. Similarly, the debug output for a table, map, list or bytearray type may be very large. The output is the string representation of object. |
Returns | Nothing |
isDebugEnabled
This function states if debugging has been enabled for the workflow. A debug event is only sent if isDebugEnabled
returns True
.
Parameter | Description |
---|---|
Returns | True or False depending on if debug is enabled or not |
MIM Related Functions
mimGet
This function returns the value of a MIM resource available in the workflow.Â
Parameter | Description |
---|---|
| The name of the agent or workflow that owns the MIM resource |
| The name of the MIM resource whose value is to be returned |
Returns | The MIM value. |
mimSet
This function assigns a value to a user defined MIM resource. The function may be called at any time. Note that it is the responsibility of the user to make sure the MIM value is available in accordance with the specified assigned type.
Parameter | Description |
---|---|
| The name of the MIM resource to assign a value |
| The value to assign, which must match the published MIM type |
Returns | Nothing |
Misc Functions
abort
This function stops the workflow, and logs a user defined message to the System Log.Â
Parameter | Description |
---|---|
| The message that is sent to the System Log when the workflow is aborted |
Returns | Nothing |
wfStop
This function stops a running workflow. wfStop
produces a single stop signal and does not wait for the workflow to stop. If it succeeds in stopping the workflow, the stop is registered in the System Log.Â
Parameter | Description |
---|---|
| You must provide the name of the workflow to be stopped. |
| For a real-time workflow, the |
Returns | If the command is successful the value is |
isStopped
This function states if the workflow has been stopped.
Parameter | Description |
---|---|
Returns | True or False depending on if workflow has been stopped or not |
Dynamic Functions
dynamicFieldGet
This function retrieves the stated dynamic field from the workflow instance table. The returned value can either be a boolean, an integer, or a string.Â
Parameter | Description |
---|---|
| The cateogry of the dynamic field |
| The name of the dynamic field |
Returns | The value of the selected dynamic field |
Timeout Functions
setTimeout
A timeout can be set to trigger delayed actions, see the def timeout(obj)
function block in Function Blocks for Agents in Real-Time Workflows. The timeout is in seconds. Setting a timeout on an object sets or updates the current timeout in seconds on that object. A timeout is triggered once on the object, and then it has to be set again to be repeated.
Parameter | Description |
---|---|
| The object can be of any type |
| The timeout in seconds |
Returns | Nothing |
removeTimeout
A timeout can be removed, see the def timeout(obj)
function block in Function Blocks for Agents in Real-Time Workflows. The timeout is in seconds.
Parameter | Description |
---|---|
obj | The same object as used in |
Returns | Nothing |
Log Related Functions
logInformation
This function logs a message string to the System Log of type information.
Parameter | Description |
---|---|
| A message appearing in the log |
Returns | Nothing |
logWarning
This function logs a message string to the System Log of type warning.
Parameter | Description |
---|---|
message | A message appearing in the log |
Returns | Nothing |
logError
This function logs a message string to the System Log of type error.
Parameter | Description |
---|---|
| A message appaering in the log |
Returns | Nothing |
logException
This function logs the current exception to the System Log.
Parameter | Description |
---|---|
Returns | Nothing |
formatException
This function formats the current exception and returns the string.
Parameter | Description |
---|---|
Returns | The current exception formatted as a string |
 Functions for Python Agents in Batch Workflows Only
The following functions only apply for the Python agents in batch workflows.
beginBatch
This function starts a new batch.
Parameter | Description |
---|---|
Returns | Nothing |
endbatch
This function ends the current batch.
Parameter | Description |
---|---|
Returns | Nothing |
cancelBatch
This function emits a Cancel Batch that aborts the processing of the current batch and possibly continues with the next batch (depending on the workflow configuration).
Parameter | Description |
---|---|
| A message, which is logged to the System Log when the batch is cancelled. |
| It is possible to send an error UDR containing any useful information. This parameter is optional. |
Returns | Nothing |
splitBatch
When invoked, this function propagates to the other agents that the input batch will be split.
Parameter | Description |
---|---|
Returns | Nothing |
hintEndBatch
This function sends a Hint End Batch message to the collection agent in the workflow, possibly causing a split of the current batch being processed.
Parameter | Description |
---|---|
Returns | Nothing |
getTransactionId
This function returns the current transaction id, or None
if there is currently no active transaction.
Parameter | Description |
---|---|
Returns | The current transaction id or |