public class

PythonInterpreter

extends Object
implements ICommandInterpreter
java.lang.Object
   ↳ com.pnfsoftware.jeb.client.script.PythonInterpreter

Class Overview

Python interpreter using Jython.

TODO: context reset TODO: history saved across JEB sessions (client side)

Summary

Public Constructors
PythonInterpreter(File jythonJar, File scriptsDir, IClientContext ctx)
Create a Python command interpreter that may interact with JEB objects.
Public Methods
boolean addToSystemPath(File dir)
AutocompletionResult autoComplete(String command)
Provide a best-effort completion suggestion for the provided partial command.
ExecutionResult executeCommand(String command)
Execute a command.
ExecutionResult executeInternal(String command, boolean allowAutoImport)
String getBanner()
Retrieve the interpreter's banner/logo string.
String getDescription()
Get the long name or description.
String getName()
Get the (short) name of this interpreter.
TypeInfoProvider getTypeInfoProvider()
void injectObject(String name, Object value)
boolean isAllowAutoImport()
void prepare()
Interpreters may place resource intensive preparation operations here.
void setAllowAutoImport(boolean allowAutoImport)
void setTypeInfoProvider(TypeInfoProvider typeinfoprv)
boolean shouldDisplayRawResults()
Determine whether this interpreter prefers that the results of executed commands be printed as-is.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.util.interpreter.ICommandInterpreter

Public Constructors

public PythonInterpreter (File jythonJar, File scriptsDir, IClientContext ctx)

Create a Python command interpreter that may interact with JEB objects.

Parameters
jythonJar jython.jar to be used - may not be specified if a scripts directory is provided, in which case, the most appropriate jython.jar file will be searched for
scriptsDir standard scripts directory, will be added to the interpreter's sys.path for easy import - may not be specified if a jython.jar was provided, in which case, the containing folder will be used
ctx optional JEB context - if provided, the context object will be made available as a global variable `jeb`
Throws
Exception
JebException

Public Methods

public boolean addToSystemPath (File dir)

public AutocompletionResult autoComplete (String command)

Provide a best-effort completion suggestion for the provided partial command.

Returns
  • optional auto-completion result object

public ExecutionResult executeCommand (String command)

Execute a command.

public ExecutionResult executeInternal (String command, boolean allowAutoImport)

public String getBanner ()

Retrieve the interpreter's banner/logo string.

Returns
  • optional string that client code (shells) may display when the interpreter was just instantiated

public String getDescription ()

Get the long name or description.

Returns
  • optional string

public String getName ()

Get the (short) name of this interpreter.

Returns
  • non-null string

public TypeInfoProvider getTypeInfoProvider ()

public void injectObject (String name, Object value)

public boolean isAllowAutoImport ()

public void prepare ()

Interpreters may place resource intensive preparation operations here. Clients may optionally call this method before invoking either: executeCommand(String) or 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.

public void setAllowAutoImport (boolean allowAutoImport)

public void setTypeInfoProvider (TypeInfoProvider typeinfoprv)

public boolean shouldDisplayRawResults ()

Determine whether this interpreter prefers that the results of executed commands be printed as-is. Clients decide whether or not they want to follow this guideline.