Class JebPythonInterpreter
java.lang.Object
com.pnfsoftware.jeb.client.script.JebPythonInterpreter
- All Implemented Interfaces:
ICommandInterpreter
Python interpreter using Jython.
-
Constructor Summary
ConstructorsConstructorDescriptionJebPythonInterpreter
(File scriptsDir, IClientContext ctx) Create a Python command interpreter able to interact with JEB objects. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addToSystemPath
(File dir) autoComplete
(String command) Provide a best-effort completion suggestion for the provided partial command.executeCommand
(String command) Execute a command.executeInternal
(String command, boolean allowAutoImport) Retrieve the interpreter's banner/logo string.Get the long name or description.getName()
Get the (short) name of this interpreter.void
injectObject
(String name, Object value) boolean
void
prepare()
Interpreters may place resource intensive preparation operations here.void
setAllowAutoImport
(boolean allowAutoImport) void
setTypeInfoProvider
(TypeInfoProvider typeinfoprv) boolean
Determine whether this interpreter prefers that the results ofexecuted commands
be printed as-is.
-
Constructor Details
-
JebPythonInterpreter
Create a Python command interpreter able to interact with JEB objects.- Parameters:
scriptsDir
- optional scripts directory, will be added to the interpreter'ssys.path
for easy importctx
- optional JEB context - if provided, the context object will be made available as a global variable `jeb`- Throws:
Exception
JebException
-
-
Method Details
-
setAllowAutoImport
public void setAllowAutoImport(boolean allowAutoImport) -
isAllowAutoImport
public boolean isAllowAutoImport() -
setTypeInfoProvider
-
getTypeInfoProvider
-
addToSystemPath
-
prepare
public void prepare()Description copied from interface:ICommandInterpreter
Interpreters may place resource intensive preparation operations here. Clients may optionally call this method before invoking either:ICommandInterpreter.executeCommand(String)
orICommandInterpreter.autoComplete(String)
. Clients may decide to not call thsi method. An interpreter implementation must handle cases where prepare() is never called, sometimes called, called multiple times, etc.- Specified by:
prepare
in interfaceICommandInterpreter
-
injectObject
- Throws:
ScriptExecutionException
-
executeCommand
Description copied from interface:ICommandInterpreter
Execute a command.- Specified by:
executeCommand
in interfaceICommandInterpreter
- Returns:
-
executeInternal
-
getAutoImportedTypes
-
getName
Description copied from interface:ICommandInterpreter
Get the (short) name of this interpreter.- Specified by:
getName
in interfaceICommandInterpreter
- Returns:
- non-null string
-
getDescription
Description copied from interface:ICommandInterpreter
Get the long name or description.- Specified by:
getDescription
in interfaceICommandInterpreter
- Returns:
- optional string
-
getBanner
Description copied from interface:ICommandInterpreter
Retrieve the interpreter's banner/logo string.- Specified by:
getBanner
in interfaceICommandInterpreter
- Returns:
- optional string that client code (shells) may display when the interpreter was just instantiated
-
shouldDisplayRawResults
public boolean shouldDisplayRawResults()Description copied from interface:ICommandInterpreter
Determine whether this interpreter prefers that the results ofexecuted commands
be printed as-is. Clients decide whether or not they want to follow this guideline.- Specified by:
shouldDisplayRawResults
in interfaceICommandInterpreter
- Returns:
-
autoComplete
Description copied from interface:ICommandInterpreter
Provide a best-effort completion suggestion for the provided partial command.- Specified by:
autoComplete
in interfaceICommandInterpreter
- Returns:
- optional auto-completion result object
-