10.19. EnSight Embedded Python (EEP) File Format

The EnSight Embedded Python file format is a mechanism that allows a user to create portable archives of data files and scripts that can be opened and read by EnSight through its Python interpreter. The file format itself is the standard ZIP format used by many tools (for example, WinZip, 7-Zip, PKZIP, zip, built into Windows and OSX, etc). To change an existing ZIP file into a EEP file, simply change its name to end in .eep. EnSight will recognize these files when passed on the command line, dropped on the running application, run by the play: command or opened via the command dialog. When presented with an EEP file, EnSight scans its contents looking for the presence of a file named __init__.py or autoexec.py. If files by both names are found in the EEP archive, it treats the file as if only the autoexec.py file was found. The two cases are handled as outlined below:

10.19.1. The "module" case ("__init__.py")

If EnSight detects a file named __init__.py, it treats the contents of the file as an EnSight module. It will extract all of the files in the EEP archive into a new, temporary directory located in the same directory as the EEP file. If EnSight cannot create a directory in that location, the operation will fail.


Note:  When EnSight exits, the temporary directory and all of its contents will be deleted. The directory which contains the temporary will be added to the EnSight Python interpreter sys.path and the temporary directory will be imported as a module using the 'import' command. As a result, the __init__.py file will be executed by EnSight and the __file__ variable will point to the __init__.py file. If the same EEP file is opened a second time in a session, the files will not be re-extracted, but reload() will be called on the module and __init__.py executed a second time.


10.19.2. The "installer" case ("autoexec.py")

If EnSight detects a file named autoexec.py, it will extract the contents of the file as a string and execute it as Python code (similar to the exec() function). One special variable will be set up before the string is executed. The Python variable '__file__' will be set to the (string) name of the EEP file. Therefore, the Python code in autoexec.py can access the EEP file contents using the name in the '__file__' variable and Python modules such as 'zipfile'. An advantage of this approach is that it does not require write access to the filesystem or the space to uncompress the data. This approach requires a more complex user written Python script, but should be used when the data in the EEP file is large, the filesystem is read only (for example, CDROM) or only a portion of the data in the file is needed.

10.19.3. Usage notes

The EEP file is a very general mechanism for packaging data and scripts in a portable fashion and getting EnSight to perform scripted operations. It can be useful for creating demos, building installers for EnSight enhancements, performing automated testing and other tasks. The use of the Python interpreter inside of the EnSight application itself greatly simplifies the run-time environment for such applications.