日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java scriptrunner_ScriptRunner.java

發布時間:2025/4/16 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java scriptrunner_ScriptRunner.java 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ScriptRunner.java

上一篇 /

下一篇 ?2012-03-19 15:05:42

/ 個人分類:android

package com.android.monkeyrunner;

import org.python.core.Py;

import org.python.core.PyObject;

import org.python.util.PythonInterpreter;

import org.python.util.InteractiveConsole;

import java.io.File;

import java.io.IOException;

import java.io.FileInputStream;

import java.lang.RuntimeException;

import java.util.Properties;

/***

* Runs Jython based scripts.

*/

public class ScriptRunner {

/*** The "this" scope object for scripts. */

private final Object scope;

private final String variable;

/*** Private constructor. */

private ScriptRunner(Object scope, String variable) {

this.scope = scope;

this.variable = variable;

}

/*** Creates a new instance for the given scope object. */

public static ScriptRunner newInstance(Object scope, String variable) {

return new ScriptRunner(scope, variable);

}

/***

* Runs the specified Jython script. First runs the initialization script. to

* preload the appropriate client library version.

*/

public static void run(String scriptfilename) {

try {

initPython();

PythonInterpreter python = new PythonInterpreter();

python.execfile(scriptfilename);

} catch(Exception e) {

e.printStackTrace();

}

}

/*** Initialize the python interpreter. */

private static void initPython() {

Properties props = new Properties();

// Default is 'message' which displays sys-package-mgr bloat

// Choose one of error,warning,message,comment,debug

props.setProperty("python.verbose", "error");

props.setProperty("python.path", System.getProperty("java.class.path"));

PythonInterpreter.initialize(System.getProperties(), props, new String[] {""});

}

/***

* Create and run a console using a new python interpreter for the test

* associated with this instance.

*/

public void console() throws IOException {

initPython();

InteractiveConsole python = new InteractiveConsole();

initInterpreter(python, scope, variable);

python.interact();

}

/***

* Start an interactive python interpreter using the specified set of local

* variables. Use this to interrupt a running test script. with a prompt:

*

* @param locals

*/

public static void console(PyObject locals) {

initPython();

InteractiveConsole python = new InteractiveConsole(locals);

python.interact();

}

/***

* Initialize a python interpreter.

*

* @param python

* @param scope

* @throws IOException

*/

public static void initInterpreter(PythonInterpreter python, Object scope, String variable)

throws IOException {

// Store the current test case as the this variable

python.set(variable, scope);

}

}

TAG:

我來說兩句

顯示全部

內容

昵稱

驗證

提交評論

總結

以上是生活随笔為你收集整理的java scriptrunner_ScriptRunner.java的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。