User`s guide
Sample programs
91
RCI callback
An RCI callback involves two types of actions, demonstrated in the following programs:
Making RCI requests from Python applications
Extending RCI to allow iDigi to make requests of Python applications. This is known as
an RCI callback.
Make an RCI request-example program
import rci (1)
request_string=""" (2)
<rci_request version="1.1">
<query_state>
<interface_info name="eth0">
<ip/>
</interface_info>
</query_state>
</rci_request>
"""
print rci.process_request(request_string) (3)
Program notes
1 The rci module includes the process_request function needed by the program.
2 A string representing the RCI request is needed. The sample uses the Python multi-line
string syntax to make it clearer that the XML represents a request for the current IP address
of the Ethernet interface. Combining the lines into a single string on one line would work in
the same way.
3 The RCI XML is submitted for parsing, and the resulting string is returned. In this sample,
the result is simply printed.