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
add_log_path(log_type: LOG_TYPE, path: str)

Add the log path for the script.

Parameters
  • log_type (LOG_TYPE) – Type of log

  • path (str) – Path of the log.

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

str

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.

@on_script_stopped(script: Node, state: NODESTATE)

Event triggered every time the execution of the script is stopped.

          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