本文整理汇总了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);
}
}
示例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;
}
}
示例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));
}
}
示例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());
}
}
示例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;
}
示例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")));
}