public class JythonUtil
extends java.lang.Object
JythonUtil,
https://sourceforge.net/p/autoplot/bugs/1310/| Constructor and Description |
|---|
JythonUtil() |
| Modifier and Type | Method and Description |
|---|---|
static InteractiveInterpreter |
createInterpreter(boolean appContext,
boolean sandbox)
create an interpreter object configured for Autoplot contexts:
QDataSets are wrapped so that operators are overloaded.
|
static InteractiveInterpreter |
createInterpreter(boolean appContext,
boolean sandbox,
Application dom,
ProgressMonitor mon)
create a Jython interpreter, with the dom and monitor available to the
code.
|
static void |
invokeScript20181217(java.net.URI uri,
java.io.File file,
Application dom,
java.util.Map<java.lang.String,java.lang.String> fparams,
ProgressMonitor mon)
Invoke the script on the current thread.
|
static void |
invokeScriptNow(java.util.Map<java.lang.String,java.lang.Object> environ,
java.io.File file)
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.
|
static void |
invokeScriptSoon(java.net.URI uri)
invoke the Jython script on another thread.
|
static int |
invokeScriptSoon(java.net.URI uri,
Application dom,
java.util.Map<java.lang.String,java.lang.String> params,
boolean askParams,
boolean makeTool,
JythonRunListener runListener,
ProgressMonitor mon1)
invoke the Jython script on another thread.
|
static int |
invokeScriptSoon(java.net.URI uri,
Application dom,
java.util.Map<java.lang.String,java.lang.String> vars,
boolean askParams,
boolean makeTool,
ProgressMonitor mon1)
invoke the Jython script on another thread.
|
static void |
invokeScriptSoon(java.net.URI uri,
Application dom,
ProgressMonitor mon)
invoke the Jython script on another thread.
|
static int |
invokeScriptSoon(java.net.URI uri,
java.io.File file,
Application dom,
java.util.Map<java.lang.String,java.lang.String> params,
boolean askParams,
boolean makeTool,
JythonRunListener jythonRunListener,
ProgressMonitor mon1)
invoke the Jython script on another thread.
|
static void |
invokeScriptSoon(java.net.URL url)
Deprecated.
use invokeScriptSoon with URI.
|
static int |
invokeScriptSoon(java.net.URL url,
Application dom,
java.util.Map<java.lang.String,java.lang.String> params,
boolean askParams,
boolean makeTool,
ProgressMonitor mon1)
Deprecated.
use invokeScriptSoon with URI.
|
static void |
invokeScriptSoon(java.net.URL url,
Application dom,
ProgressMonitor mon)
Deprecated.
use invokeScriptSoon with URI.
|
static void |
runScript(Application dom,
java.io.InputStream in,
java.lang.String name,
java.lang.String[] argv,
java.lang.String pwd)
Run the script in the input stream.
|
protected static void |
runScript(ApplicationModel model,
java.io.InputStream in,
java.lang.String name,
java.lang.String[] argv,
java.lang.String pwd)
Run the script in the input stream.
|
protected static void |
runScript(ApplicationModel model,
java.lang.String script,
java.lang.String[] argv,
java.lang.String pwd) |
static int |
showScriptDialog(java.awt.Component parent,
java.util.Map<java.lang.String,java.lang.Object> env,
java.io.File file,
java.util.Map<java.lang.String,java.lang.String> fparams,
boolean makeTool,
java.net.URI resourceUri)
show the script and the variables (like we have always done with jyds scripts), and offer to run the script.
|
public static InteractiveInterpreter createInterpreter(boolean appContext,
boolean sandbox)
throws java.io.IOException
appContext - load in additional symbols that make sense in application context.sandbox - limit symbols to safe symbols for server.java.io.IOExceptionpublic static InteractiveInterpreter createInterpreter(boolean appContext,
boolean sandbox,
Application dom,
ProgressMonitor mon)
throws java.io.IOException
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.java.io.IOExceptionprotected static void runScript(ApplicationModel model, java.lang.String script, java.lang.String[] argv, java.lang.String pwd) throws java.io.IOException
java.io.IOExceptionprotected static void runScript(ApplicationModel model, java.io.InputStream in, java.lang.String name, java.lang.String[] argv, java.lang.String pwd) throws java.io.IOException
model - 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.java.io.IOExceptionpublic static void runScript(Application dom, java.io.InputStream in, java.lang.String name, java.lang.String[] argv, java.lang.String pwd) throws java.io.IOException
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.java.io.IOExceptionpublic static void invokeScriptSoon(java.net.URL url)
throws java.io.IOException
url - the address of the script.java.io.IOExceptionpublic static void invokeScriptSoon(java.net.URI uri)
throws java.io.IOException
uri - the address of the script.java.io.IOExceptionpublic static void invokeScriptSoon(java.net.URL url,
Application dom,
ProgressMonitor mon)
throws java.io.IOException
url - the address of the script.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.java.io.IOExceptionpublic static void invokeScriptSoon(java.net.URI uri,
Application dom,
ProgressMonitor mon)
throws java.io.IOException
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.java.io.IOExceptionpublic static int showScriptDialog(java.awt.Component parent,
java.util.Map<java.lang.String,java.lang.Object> env,
java.io.File file,
java.util.Map<java.lang.String,java.lang.String> fparams,
boolean makeTool,
java.net.URI resourceUri)
throws java.io.IOException
parent - parent GUI to followenv - 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.java.io.IOExceptionpublic static int invokeScriptSoon(java.net.URL url,
Application dom,
java.util.Map<java.lang.String,java.lang.String> params,
boolean askParams,
boolean makeTool,
ProgressMonitor mon1)
throws java.io.IOException
url - the address of the script.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).mon1 - monitor to detect when script is finished. If null, then a NullProgressMonitor is created.java.io.IOExceptionpublic static int invokeScriptSoon(java.net.URI uri,
Application dom,
java.util.Map<java.lang.String,java.lang.String> vars,
boolean askParams,
boolean makeTool,
ProgressMonitor mon1)
throws java.io.IOException
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.java.io.IOExceptionpublic static int invokeScriptSoon(java.net.URI uri,
Application dom,
java.util.Map<java.lang.String,java.lang.String> params,
boolean askParams,
boolean makeTool,
JythonRunListener runListener,
ProgressMonitor mon1)
throws java.io.IOException
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.java.io.IOExceptionpublic static void invokeScriptNow(java.util.Map<java.lang.String,java.lang.Object> environ,
java.io.File file)
throws java.io.IOException,
PyException
environ - file - java.io.IOExceptionPyExceptionwhich doesn't allow for control of the environ (and arbitrary parameters).public static int invokeScriptSoon(java.net.URI uri,
java.io.File file,
Application dom,
java.util.Map<java.lang.String,java.lang.String> params,
boolean askParams,
boolean makeTool,
JythonRunListener jythonRunListener,
ProgressMonitor mon1)
throws java.io.IOException
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.java.io.IOExceptionpublic static void invokeScript20181217(java.net.URI uri,
java.io.File file,
Application dom,
java.util.Map<java.lang.String,java.lang.String> fparams,
ProgressMonitor mon)
throws java.io.IOException
uri - the URI, providing pwd.file - null or the file to use.dom - the applicationfparams - parameters to pass into the script.mon - feedback monitor for the thread.java.io.IOException