iagctl run service python-script
iagctl run service python-script
Run a Python script service.
The iagctl run service python-script command executes a Python script service and displays the resulting stdout, stderr, return code, and execution time information.
Syntax
Usage notes
Runtime arguments
Use the --set flag to pass arguments to the Python script. IAG passes each value to the script in --key=value format. For example, this command:
Causes IAG to run the following in the virtual environment:
If you defined a decorator during service creation, IAG validates all --set values against it before passing them to the script.
You can also pass a bare --set key without a value. How IAG passes this to your script depends on whether the service has a decorator with the property defined as boolean:
- With a decorator: IAG passes the flag as
--verbose - Without a decorator: IAG passes the flag as
--verbose=trueFor more information and script examples for both cases, see Boolean properties in Python script services.
Your script parses these arguments using Python’s argparse module. The following example handles string values, JSON inputs, and a boolean flag:
View accepted inputs
Use the --use flag with the service name to display information about the inputs a service accepts:
Examples
Run a Python script service
Run a Python script service with arguments
The following example passes device and commands arguments to the script.