You copied the Doc URL to your clipboard.

Scripting View

Attention: This feature requires a valid license to use.

While using GA, you may find that you would like to extract or analyze information retrieved from the target device, but the user interface doesn't have the tools that you need. For this purpose, GA has a Python scripting environment that allows you to directly interface with GA's trace model. You can use this to either perform an analysis natively in Python, or output the data you need to an external file.

The Jython Interpreter

The Scripting View contains a Jython interpreter that implements the Python 2.7.0 specification. The interpreter supports the standard Python syntax and you can also import modules from the Python standard library.

There is one interpreter per trace file. These interpreters cannot share data. Closing the Scripting View closes all interpreters.

Note: The import keyword is only valid for the Python standard library. The interpreter only supports loading external code in the form of scripts that must be run from the Scripting View. After a script completes, all top-level declarations (variables, function definitions, class definitions, etc) will persist in the scripting environment.

For convenience, the interpreter is initialized with two additional global variables:

  • trace, a representation of the GA internal model.
  • monitor, an interface to the progress bar underneath the interpreter input text area. You can use this to track progress inside your scripts.
For more information about these objects, or any other GA object, you can use the built-in Python help function to print API documentation. For example:
GA also comes with some sample scripts inside /path/to/installation/samples/scripts/ that provide examples of different ways to perform analysis on a trace object.

The Scripting Console

The scripting console allows you to interact with the Jython interpreter.

You can use the Up and Down keys to move through a history of the commands you have previously executed.

Pressing the Interrupt button will cause any running script and any created threads to stop.

The Clear button allows you to clear the output text area.

To reset the interpreter back to its original state, press the Reset button.

Loading Scripts

The Scripting View contains an interactive interpreter, but for more complicated analysis it is easier to write a script in a separate Python file. The Scripting View also allows you to load Python scripts (or directories of Python scripts) from your file system. GA only loads scripting files with the .py extension.

The scripts you load are stored in your workspace and are persistent across runs of GA.

To load a single script press the Add Script button.

To load a directory press the Add Directory button. File-system changes to this directory will be reflected in GA.

To remove any top level item press the Remove button. This does not affect the file or directory on the file-system.

Scripts are loaded and displayed in a staging area next to the interpreter. To execute a script, either double click it or highlight it in the staging area and either right-click and select Run or press the R key.

Performance Considerations

The scripting environment is potentially very powerful, but also potentially very memory intensive. Especially if your trace is very large, the following tips may help improve the performance of your scripts:

  • Holding global references to objects that you no longer need will waste memory. You can delete an individual reference with the del keyword or use the Reset button to re-initialize the scripting environment, deleting all references.
  • You can keep memory usage low by only touching the parts of the model that you are specifically interested in.
  • Traversing the model forwards will be faster than traversing backwards.
  • Printing excessively large strings to the interpreter console can slow down the GA user interface. If you need to write large strings, you may want to write to an external file rather than the scripting console.
Was this page helpful? Yes No