Python Scripts

Edgar contains an embedded Python interpreter(1) to facilitate enhancement and rapid application development for specific end-user requirements using Python. This makes it easy for individual users to create customized acquisition(2) and processing(3) scripts.

If you are not yet familiar with Python, you can think of it as a macro language embedded into Edgar, and start by modifying the simple examples provided with your Edgar installation to suit your needs. If you are already familiar with Python, then you’ll quickly be able to use the more complex examples to learn the Edgar API, and start developing your own custom applications.

Python scripts are fully interactive within Edgar. You can run a script, edit it, and run it again, all without having to close and restart Edgar. Current debugging tools within Edgar are limited to catching errors in the scripts and displaying an error window with the line number within the script where the error occurs, and a description of the error.

Whenever a script is running, the script name is displayed inside brackets in the Edgar window title bar. This way it is easy to recognize if a script is running. It is also possible to run multiple scripts at the same time, in which case multiple script names will show up in the title bar. With scripts running you still have normal GUI access with keyboard and mouse.

There are three access points for Python from Edgar: as an interactive command line shell, as an automatically executed program or script launched at startup, and as a program or script launched after startup.

You can open an interactive shell from the Shell tab at the bottom of the Edgar window. This allows you to execute commands in an interactive mode, one at a time.

To launch a script automatically when Edgar starts up, specify a startup script(4) under the Acquisition tab of the Preferences editor. If no script is specified, none is executed. On this same tab is the Enable Python shell and Python script execution option, which allows the embedded Python interpreter in Edgar to be turned on and off. The default is to have this turned off. Just check the box and restart Edgar to turn it on.

Under Tools, Execute Script you can open a file chooser that will let you open and execute a script file. Find your file, select it, and it will open and run under Edgar. By default, Edgar looks for scripts with a .py extension in a Python folder underneath your Edgar installation folder. You can open and edit the Python script files using the built-in script editor at Tools, Edit Script. You can also use any ASCII text editor.

There are a few things that you can do from Python that you can’t do at all directly from Edgar, such as:

(1)Jython v2.5.0

(2)Used to automate data acquisition by setting up for a Remote Start in a loop, collecting a set of files with specific names, etc.

(3)Used to to automate data processing.

(4)If you find yourself performing the same sequence of operations after every Edgar startup, then you need a startup script.