本文整理汇总了Java中org.python.util.InteractiveConsole类的典型用法代码示例。如果您正苦于以下问题:Java InteractiveConsole类的具体用法?Java InteractiveConsole怎么用?Java InteractiveConsole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InteractiveConsole类属于org.python.util包,在下文中一共展示了InteractiveConsole类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JythonInterpreter
import org.python.util.InteractiveConsole; //导入依赖的package包/类
public JythonInterpreter() throws IOException {
is = new PipedInputStream();
os = new PipedOutputStream();
pis = new PipedInputStream(os);
pos = new PipedOutputStream(is);
System.setProperty(TerminalFactory.JLINE_TERMINAL, "none");
AnsiConsole.systemInstall();
Ansi.setDetector(new AnsiDetector());
shell = new InteractiveConsole();
shell.setIn(pis);
shell.setOut(pos);
shell.setErr(pos);
}
示例2: runInteractive
import org.python.util.InteractiveConsole; //导入依赖的package包/类
private static void runInteractive() {
//String path = GlobalUtil.getAppPath(FrmMain.class) + File.separator + "pylib";
InteractiveConsole console = new InteractiveConsole();
try {
//console.set("mis", mis);
console.exec("import sys");
//console.exec("sys.path.append('" + path + "')");
//console.exec("from milab import *");
//console.exec("mipylib.miplot.isinteractive = True");
} catch (Exception e) {
e.printStackTrace();
}
console.interact();
}
示例3: perform
import org.python.util.InteractiveConsole; //导入依赖的package包/类
@Override
public void perform() throws Failure
{
// The delegate interface is carefully designed to keep the API public,
// but keep the knowledge of ModelRoot, Selection, and ChangeConstructions, etc. here.
Command.Delegate delegate = this .createDelegate();
Properties props = new Properties();
props .setProperty( "python.path", "/Library/Python/2.7/site-packages" );
// TODO this could be done once, when the python console is opened
InteractiveConsole.initialize( System.getProperties(), props, new String[0] );
PythonInterpreter interp = new PythonInterpreter();
interp .setOut( System.out );
interp .setErr( System.err );
interp .set( "javaCommand", new Command( delegate ) );
try {
interp .exec( "import vzome" );
interp .exec( "command = vzome.Command( cmd=javaCommand )" );
interp .exec( this .programText );
} catch ( PyException e ) {
e.printStackTrace();
throw new Failure( e.toString() );
}
redo();
}
示例4: newInterpreter
import org.python.util.InteractiveConsole; //导入依赖的package包/类
@Override
public PythonInterpreter newInterpreter() {
PythonInterpreter interpreter = new InteractiveConsole();
interpreter.set("bc", bc);
interpreter.exec("import sys");
PySystemState sys = (PySystemState) interpreter.get("sys");
sys.setClassLoader(getClass().getClassLoader());
return interpreter;
}
示例5: run
import org.python.util.InteractiveConsole; //导入依赖的package包/类
public void run(String[] args) {
String name = null;
if (args.length > 0)
name = args[0];
InteractiveConsole interpreter = getInterpreter(name);
JythonOutputStream os = new JythonOutputStream(context);
interpreter.setOut(os);
interpreter.setErr(os);
try {
boolean more = false;
while (true) {
String line;
try {
context.print(more ? "... " : ">>> ");
line = context.readLine();
} catch (PyException exc) {
if (!exc.match(Py.EOFError))
throw exc;
break;
}
more = interpreter.push(line);
}
} catch (InterruptedException e) {
context.println("interrupted");
}
}
示例6: setLocalsTo
import org.python.util.InteractiveConsole; //导入依赖的package包/类
@Override
public void setLocalsTo(PyObject locals) {
interactiveConsole = new InteractiveConsole();
interactiveConsole.setLocals(locals);
}
示例7: console
import org.python.util.InteractiveConsole; //导入依赖的package包/类
/**
* Start an interactive python interpreter.
*/
public static void console(String executablePath) {
initPython(executablePath);
InteractiveConsole python = new JLineConsole();
python.interact();
}