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


Java PyFunction.__call__方法代码示例

本文整理汇总了Java中org.python.core.PyFunction.__call__方法的典型用法代码示例。如果您正苦于以下问题:Java PyFunction.__call__方法的具体用法?Java PyFunction.__call__怎么用?Java PyFunction.__call__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.python.core.PyFunction的用法示例。


在下文中一共展示了PyFunction.__call__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onHandleIntent

import org.python.core.PyFunction; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent workIntent) {
	try {
		String callback = workIntent.getExtras().getString("com.runassudo.pyandroid.CALLBACK");
		
		PyFunction callbackR = ((PyAndroidApplication) getApplicationContext()).callbacks.get(callback);
		if (callbackR != null) {
			callbackR.__call__();
		} else {
			throw new NullPointerException("Tried to call undefined callback " + callback);
		}
	} catch (Exception e) {
		mHandler.post(new Runnable() {
			@Override
			public void run() {
				Toast.makeText(PyService.this, "An error occurred!", Toast.LENGTH_LONG).show();
			}
		});
		Log.e("PyAndroid", "An error occurred!", e);
	}
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:22,代码来源:PyService.java

示例2: callFunc

import org.python.core.PyFunction; //导入方法依赖的package包/类
public static boolean callFunc(String funcName, Object... binds) {
	try {
		PyObject obj = ScriptManager.python.get(funcName);
		if (obj != null && obj instanceof PyFunction) {
			PyFunction func = (PyFunction) obj;
			PyObject[] objects = new PyObject[binds.length];
			for (int i = 0; i < binds.length; i++) {
				Object bind = binds[i];
				objects[i] = Py.java2py(bind);
			}
			func.__call__(objects);
			return true;
		} else
			return false;
	} catch (PyException ex) {
		ex.printStackTrace();
		return false;
	}
}
 
开发者ID:Jarinus,项目名称:osrs-private-server,代码行数:20,代码来源:ScriptManager.java

示例3: onDestroy

import org.python.core.PyFunction; //导入方法依赖的package包/类
@Override
public void onDestroy() {
	super.onDestroy();
	
	try {
		PyFunction callbackR = ((PyAndroidApplication) getApplicationContext()).callbacks.get("_stop");
		if (callbackR != null) {
			callbackR.__call__();
		}
	} catch (Exception e) {
		Log.w("PyAndroid", "An error occurred while stopping.", e);
		appendLog("An error occurred while stopping.");
		appendLog(Log.getStackTraceString(e));
	}
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:16,代码来源:LaunchPyService.java

示例4: invoke

import org.python.core.PyFunction; //导入方法依赖的package包/类
public void invoke(String method) {
    PyObject obj = (PyObject) this.bindings.get(method);
    if (obj == null) {
        failz0r(world, pos, "Unknown function '%s'", method);
        return;
    }
    PyFunction func = (PyFunction)obj;
    try {
        func.__call__();
    } catch (RuntimeException e) {
        failz0r(world, pos, "Error running code: %s", e.toString());
    }
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:14,代码来源:PythonCode.java

示例5: executePython

import org.python.core.PyFunction; //导入方法依赖的package包/类
private PyObject executePython(String filePath, String function){
	PythonInterpreter interpreter = new PythonInterpreter();
	Vector<AndroidDriver> drivers = new Vector();
	drivers.add(this);
	interpreter.set("device", drivers);
	interpreter.execfile(filePath);
	PyFunction pyfunction = interpreter.get(function, PyFunction.class);
	PyObject pyobj = pyfunction.__call__();
	return pyobj;
}
 
开发者ID:hoozheng,项目名称:AndroidRobot,代码行数:11,代码来源:AndroidDriver.java

示例6: transform

import org.python.core.PyFunction; //导入方法依赖的package包/类
private static PyList transform(String line, PyFunction pyTransformFunc) throws UnsupportedEncodingException {
    return (PyList) pyTransformFunc.__call__(new PyByteArray(line.getBytes("utf-8")));
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:4,代码来源:ContinuousOnlinePredictor.java


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