Writing Client Scripts¶
JEB Standard and JEB Business builds permit running scripts:
- Scripts are meant to execute small, light-weight actions
- They can be written using the Python 2.5 or 2.7 syntax and features, and are executed by a Jython VM
A Jython stand-alone package is required to run scripts.
Download either Jython 2.7 Standalone (newer, slower to load) or Jython 2.5 Standalone (older and slimmer, faster to load) and drop it in your JEB
- use the standard JEB API
- use the Client API package
- if run within a client that implements the UI-API, use the JEB UI Client API
A client script implements the
IScript interface. Upon execution, the script
run() entry-point method is provided an
IClientContext or derived object, such as an
IGraphicalClientContext for UI clients, such as the official RCP desktop client.
A Simple Script¶
Here is the simplest of all scripts:
from com.pnfsoftware.jeb.client.api import IScript class JEB2SampleScript(IScript): def run(self, ctx): print('Hello, JEB version %s' % ctx.getSoftwareVersion()) print('- Arguments: %s' % ctx.getArguments()) print('- Base directory: %s' % ctx.getBaseDirectory())
Within the official desktop client, scripts can be executed via the File, Scripts menu item.
Remember that heavy-lifting operations (such as parsing or background event-driven tasks) should be implemented by back-end plugins in Java.
Check out our GitHub repository for more sample scripts.