org.autoplot.JythonUtil
Utilities for Jython functions, such as a standard way to initialize
an interpreter and invoke a script asynchronously.
TODO: this needs review, since the autoplot.py was added to the imports.
JythonUtil( )
createInterpreter
createInterpreter( boolean appContext, boolean sandbox ) → InteractiveInterpreter
create an interpreter object configured for Autoplot contexts:
- QDataSets are wrapped so that operators are overloaded.
- a standard set of names are imported.
Parameters
appContext - load in additional symbols that make sense in application context.
sandbox - limit symbols to safe symbols for server.
Returns:
PythonInterpreter ready for commands.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
createInterpreter
createInterpreter( boolean appContext, boolean sandbox, org.autoplot.dom.Application dom, ProgressMonitor mon ) → InteractiveInterpreter
create a Jython interpreter, with the dom and monitor available to the
code.
Parameters
appContext - run this in the application context, with access to the dom. (TODO: this is probably always equivalent to dom!=null)
sandbox - limit symbols to safe symbols for server.
dom - the application state, if available.
mon - a monitor, if available. If it is not a monitor is created.
Returns:
the interpreter.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScript20181217
invokeScript20181217( java.net.URI uri, java.io.File file, org.autoplot.dom.Application dom, java.util.Map fparams, ProgressMonitor mon ) → void
Invoke the script on the current thread.
Parameters
uri - the URI, providing pwd.
file - null or the file to use.
dom - the application
fparams - parameters to pass into the script.
mon - feedback monitor for the thread.
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScriptNow
invokeScriptNow( java.util.Map environ, java.io.File file ) → void
Do a search for the number of places where JythonUtil.createInterpreter
is called and it should be clear that there's a need for one code that
does this. There probably is one such code, but I can't find it right
now.
Parameters
environ - a java.util.Map
file - a File
Returns:
void (returns nothing)
See Also:
runScript(org.autoplot.ApplicationModel, java.lang.String, java.lang.String[], java.lang.String) which doesn't allow for control of the environ (and arbitrary parameters).
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScriptSoon
Deprecated: use invokeScriptSoon with URI.
invokeScriptSoon
invokeScriptSoon( java.net.URI uri ) → void
invoke the Jython script on another thread.
Parameters
uri - the address of the script.
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScriptSoon
Deprecated: use invokeScriptSoon with URI.
invokeScriptSoon
invokeScriptSoon( java.net.URI uri, org.autoplot.dom.Application dom, ProgressMonitor mon ) → void
invoke the Jython script on another thread.
Parameters
uri - the address of the script, possibly having parameters.
dom - if null, then null is passed into the script and the script must not use dom.
mon - monitor to detect when script is finished. If null, then a NullProgressMonitor is created.
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScriptSoon
Deprecated: use invokeScriptSoon with URI.
invokeScriptSoon
invokeScriptSoon( java.net.URI uri, org.autoplot.dom.Application dom, java.util.Map vars, boolean askParams, boolean makeTool, ProgressMonitor mon1 ) → int
invoke the Jython script on another thread. Script parameters can be passed in, and the scientist can be
provided a dialog to set the parameters. Note this will return before the script is actually
executed, and monitor should be used to detect that the script is finished.
Parameters
uri - the address of the script.
dom - if null, then null is passed into the script and the script must not use dom.
vars - values for parameters, or null.
askParams - if true, query the scientist for parameter settings.
makeTool - if true, offer to put the script into the tools area for use later (only if askParams).
mon1 - monitor to detect when script is finished. If null, then a NullProgressMonitor is created.
Returns:
JOptionPane.OK_OPTION of the script is invoked.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScriptSoon
invokeScriptSoon( java.net.URI uri, org.autoplot.dom.Application dom, java.util.Map params, boolean askParams, boolean makeTool, org.autoplot.JythonRunListener runListener, ProgressMonitor mon1 ) → int
invoke the Jython script on another thread. Script parameters can be passed in, and the scientist can be
provided a dialog to set the parameters. Note this will return before the script is actually
executed, and monitor should be used to detect that the script is finished.
Parameters
uri - the resource URI of the script (without parameters).
dom - if null, then null is passed into the script and the script must not use dom.
params - values for parameters, or null.
askParams - if true, query the scientist for parameter settings.
makeTool - if true, offer to put the script into the tools area for use later (only if askParams).
runListener - null or place to mark error messages and to mark as running a script.
mon1 - monitor to detect when script is finished. If null, then a NullProgressMonitor is created.
Returns:
JOptionPane.OK_OPTION of the script is invoked.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
invokeScriptSoon
invokeScriptSoon( java.net.URI uri, java.io.File file, org.autoplot.dom.Application dom, java.util.Map params, boolean askParams, boolean makeTool, org.autoplot.JythonRunListener jythonRunListener, ProgressMonitor mon1 ) → int
invoke the Jython script on another thread. Script parameters can be passed in, and the scientist can be
provided a dialog to set the parameters. Note this will return before the script is actually
executed, and monitor should be used to detect that the script is finished.
This should be called from the event thread!
Parameters
uri - the resource URI of the script (without parameters).
file - the file which has been downloaded.
dom - if null, then null is passed into the script and the script must not use dom.
params - values for parameters, or null.
askParams - if true, query the scientist for parameter settings.
makeTool - if true, offer to put the script into the tools area for use later (only if askParams).
jythonRunListener - null or place to mark error messages and to mark as running a script.
mon1 - monitor to detect when script is finished. If null, then a NullProgressMonitor is created.
Returns:
JOptionPane.OK_OPTION of the script is invoked.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
runScript
runScript( org.autoplot.dom.Application dom, java.io.InputStream in, String name, String[] argv, String pwd ) → void
Run the script in the input stream.
Parameters
dom - provides the dom to the environment.
in - stream containing script. This will be left open.
name - the name of the file for human reference, or null.
argv - parameters passed into the script, each should be name=value, or positional. The name of the script should not be the zeroth element.
pwd - the present working directory, if available. Note this is a String because pwd can be a remote folder.
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
showScriptDialog
showScriptDialog( java.awt.Component parent, java.util.Map env, java.io.File file, java.util.Map fparams, boolean makeTool, java.net.URI resourceUri ) → int
show the script and the variables (like we have always done with jyds scripts), and offer to run the script.
Parameters
parent - parent GUI to follow
env - a java.util.Map
file - file containing the script.
fparams - parameters for the script.
makeTool - the dialog is always shown and the scientist can have the script installed as a tool.
resourceUri - when the scientist decides to make a tool, we need the source location.
Returns:
JOptionPane.OK_OPTION or JOptionPane.CANCEL_OPTION if the scientist cancels.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]