当前位置: 首页>>代码示例>>Java>>正文


Java InteractiveConsole类代码示例

本文整理汇总了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);
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:16,代码来源:JythonInterpreter.java

示例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();
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoMap,代码行数:15,代码来源:Program.java

示例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();
  }
 
开发者ID:vZome,项目名称:vzome-core,代码行数:29,代码来源:RunPythonScript.java

示例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;
}
 
开发者ID:araqne,项目名称:jython,代码行数:10,代码来源:JythonServiceImpl.java

示例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");
	}
}
 
开发者ID:araqne,项目名称:jython,代码行数:30,代码来源:JythonScript.java

示例6: setLocalsTo

import org.python.util.InteractiveConsole; //导入依赖的package包/类
@Override
public void setLocalsTo(PyObject locals) {
    interactiveConsole = new InteractiveConsole();
    interactiveConsole.setLocals(locals);
}
 
开发者ID:antivo,项目名称:Parallel-Machine-Simulator,代码行数:6,代码来源:JythonInterpreter.java

示例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();
}
 
开发者ID:liuyq,项目名称:aster,代码行数:9,代码来源:ScriptRunner.java


注:本文中的org.python.util.InteractiveConsole类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。