Ciceron Integration Services  2.5.x
 All Classes Functions Variables Enumerations Properties Modules Pages
Python language

The python language is a script language that will run on many operating systems.
The script language is also extended with some object that are exclusive for the integration services as described in the Class List or Modules topics.
The language is described on an external site:
http://en.wikipedia.org/wiki/Python_(programming_language)

Note
All method and properties of the extension objects (in VB) are written in lowercase letters with an underscore between words.
Method Description
activate() Activate the task
attach_id() Attach the parameters from an existing task
attach_integration() Attach the parameters from a located integration item
attach_process() Attach the parameters from a located process item
attach_task() Attach the parameters from any located task item
attach_trigger() Attach the parameters from a located trigger item
continue_run() Check if a stop request is made for this task
create_temp_file() Create a temporary file
delete_all_parameters() Delete all of the parameters from this Task object
delete_parameter() Delete one parameter from this Task object
delete_temp_files() Delete all of the temporary files created for this task
get_activated_by() Return the name of the activator of this task
get_config_parameter() Return the value of the current configuration parameter
get_data() Return any input data for this task
get_data_file() Return the input data for this task as a temporary file
get_file_identifier() Return an identifier from the file content
get_id() Return the current id of this Task object
get_input_file() Return the input filename for this task
get_name() Return the name of this Task object
get_parameter() Return the value of a parameter
get_parameters() Return all parameter names and values
get_status() Return the status of this task
get_sub_parameter() Return the value of a sub parameter
get_workspace_id() Return the current workspace id of this Task object
is_active() Check if this task is running
load() Load the current parameters of this Task object
new_task() Create a new Task object
quit() Quit the task immediately
quit_and_restart() Quit the task immediately and place it in the restart queue
remove() Remove the information about this task
report_debug() Report a Debug message
report_event() Report an Event message
report_log() Report a Log message
set_data() Set the input data for a new task or the output data from the original task
set_data_file() Set the input data from a file for a new task or the output from a data file from the original task
set_id() Set the ID of this Task object
set_input_file() Set the input file for this task
set_parameter() Set the name and value of a parameter
set_status() Set the status of this task
sleep() Sleep for a number of seconds
store() Store any modified parameters immediately

def main(task)

This is the entry point called by the interpreter when then component should run.
It is called with the original task object as an argument.

1 # main.py
2 import integration_services as cis
3 
4 def main(task):
5  task.report_event(cis.re_normal, "hello from main.py")

The integration_services module

In the above sample, the integration_services module is imported and named cis. The cis module have the constants for instance report_event etc. The cis module also have some methods for running a different component (run_component) or for importing another module from the server (remote_import).

Getting script modules from the server

When the script is running from the agent, a different module or modules can be fetched from the server with the remote_get method. A single script component or a complete sub directory (under the component directory) can be fetched.

1 # main.py
2 import integration_services as cis
3 
4 cis.remote_get("cis")
5 
6 import cis.test as test
7 
8 def main(task):
9  test.my_method(task, "hello from test.py")

Importing script modules from the server

Same as getting script modules but the module(s) are also imported directly via remote_import.

1 # main.py
2 import integration_services as cis
3 
4 def main(task):
5  test = cis.remote_import("test.py")
6  test.my_method(task, "hello from test.py")
1 # test.py
2 import integration_services as cis
3 
4 def my_method(task, text):
5  task.report_event(cis.re_normal, text)

Getting local and remote certificates

Can be used for signing and encryptions.

1 # main.py
2 import integration_services as cis
3 
4 def main(task):
5  base64privateKey = cis.get_local_private_key() # should never leave this script
6  base64der = cis.get_local_certificate()
7  task.report_event(cis.RE_NORMAL, "local cert=" + base64der)
8  # get a remote certificate for a workspace id:
9  base64der = cis.get_remote_certificate("internal:myworkspace/default")
10  # or by using the workspace group id directly:
11  base64der = cis.get_remote_certificate("internal")
12  task.report_event(cis.RE_NORMAL, "remote cert=" + base64der)

Mockup

A python component can be tested standalone (from python.exe) by importing the integration_services.py module and check the __name__ property before calling the main entry point. No server connections are made by the mockup code so this is a great way of testing a single component. Note: The utility RunComponent can also be used to test any components standalone.

1 # [ Component | mockup test ]
2 #
3 
4 import integration_services as cis
5 
6 def main(task):
7  task.report_event(cis.re_info, "Hello world")
8 
9 if __name__ == "__main__":
10  task = cis.new_task()
11  task.set_parameter("x", "1")
12  task.set_parameter("y", "2")
13  main(task)
See also
Script component overview