Script
Summary
- In ANDi, it is possible to run scripts in parallel.
The object script provides different methods that allow to start/stop the execution of other scripts dynamically. A name of a script in the current project must be used to call these methods. In order to refer to the self-script, it is possible to use the reserved word current_script.
script_1.start() # start the execution of a script present in the project
print(current_script.get_file_path()) # return the path of the current script
- Methods
- Events
Structure
- class Script
-
- get_file_path() str
Gets the full path of the script file. The script should be saved before using the reset method in order to print the path. If it's not saved the file path is an empty string.
- Returns
The full path of the script file
- Return type
- skip()
Marks the script as "skipped" and stops its execution
- start()
Starts the execution of the script.
- start(timeout: int32)
Executes the script. If the timeout is given, the started script will be stopped automatically after this time.
- Parameters
timeout (
int32
) – (optional) maximum time in the started script will be executed.
- stop()
Stops the execution of the script.
def when_script_stop(script, node_state):
if node_state == NODESTATE.STOPPED:
print("script stoped manually")
stop_computing()
current_script.on_script_stopped += when_script_stop
start_computing()
:Parameters:
- **script** (:py:class:`Node`) – Same script object which called the event
- **state** (:py:class:`NODESTATE`) – states the current script indicating why it has stopped