PythonScriptReceiver
The PythonScriptReceiver executes a Python script. The receiver validates the configured file path before execution and captures the Python script's standard output or error output.
Prerequisites
- Python must be installed and configured on the system where the Scenario is being executed.
Receiver Parameters
| Parameter | Required | Description |
|---|---|---|
| path | Yes | Base directory containing the Python script. |
| subDirectory | No | Optional subdirectory under path containing the Python script. |
| fileName | Yes | Name of the Python script to execute. |
| pythonCommand | Yes | Python executable/command used to execute the script, for example python or python3 |
| beforeLoop | No | When true, executes the Python script once before the data generation loop. |
| whileLoop | No | When true, executes the Python script during each row of the data generation loop. |
| afterLoop | No | When true, executes the Python script once after the generation loop. |
Receiver Attributes Property Keys
The Receiver defines only one property key that can be modified on any of its associated Domain Attributes:
- include - Determines if the Attribute will be included as a column in the output.
Python Script Path
The full path to the Python script is constructed using the Receiver parameters - path and fileName:
path/fileName
or, when subDirectory is specified in Receiver parameter:
path/subDirectory/fileName
For example:
- path = /data/scripts
- subDirectory = customer
- fileName = process_customer.py
Results in:
/data/scripts/customer/process_customer.py
Note: If the Python script does not exist at the resulting path, the receiver throws a GenRocketException.
Script Execution
The Python command is constructed as:
pythonCommand fullPath [attribute values...]
Each Attribute of the Domain will become the argument to Python command.
For example:
python3 /data/scripts/customer/process_customer.py John 12345
Article Feedback: Was this helpful?
Give feedback