Package org.python.core

Examples of org.python.core.PyObject$ConversionException


     *  error in calling the method.
     */
    private PyObject _invokeMethod(String methodName, Object[] args)
            throws IllegalActionException {
        PyMethod method = (PyMethod) _methodMap.get(methodName);
        PyObject returnValue = null;

        if (method != null) {
            try {
                if ((args == null) || (args.length == 0)) {
                    returnValue = method.__call__();
View Full Code Here


     @return The return value of the command, or null if there is none.
     *  @exception Exception If something goes wrong processing the command.
     */
    public String evaluateCommand(String command) throws Exception {
        try {
            PyObject results = _interpreter.eval(command);
            return results.toString();
        } catch (Throwable throwable) {
            return throwable.toString();
        }
    }
View Full Code Here

        callable = c;
        operation = op;
    }

    String apply(final String req) {
        PyObject r = callable.__call__(new PyString(req));
        return r.toString();
    }
View Full Code Here

                    return v;
                }
            }));
        }

        PyObject mkc = python.get("mkcomponent");
        callable = mkc.__call__(new PyString(component.getName()), new PyString(implementation.getScript()), new PyTuple(px.toArray(new PyObject[0])), new PyTuple(pr.toArray(new PyObject[0])));
    }
View Full Code Here

    NonCoreContract parserContract = NonCoreContract
        .getNonCoreContract("bill-parser-" + extension);
    try {
      PythonInterpreter interpreter = new PythonInterpreter();
      interpreter.exec(parserContract.getChargeScript());
      PyObject parserClass = interpreter.get("Parser");
      parser = (BillParser) parserClass
          .__call__(
              PyJavaType.wrapJavaObject(new InputStreamReader(is,
                  "UTF-8"))).__tojava__(BillParser.class);
    } catch (UnsupportedEncodingException e) {
      throw new InternalException(e);
View Full Code Here

    Object result = null;
    PythonInterpreter interp = new PythonInterpreter();
    try {
      interp.set("contract", this);
      interp.exec(chargeScript);
      PyObject function = interp.get(name);
      if (function == null) {
        throw new UserException("There isn't a function called " + name);
      }
      result = function.__call__(Py.javas2pys(args)).__tojava__(
          Object.class);
    } catch (Throwable e) {
      throw new UserException(HttpException.getStackTraceString(e));
    } finally {
      interp.cleanup();
View Full Code Here

                if (!key.startsWith("__") && !key.equals("schemaFunction")
                        && !key.equals("outputSchema")
                        && !key.equals("outputSchemaFunction")
                        && (value instanceof PyFunction)
                        && (((PyFunction)value).__findattr__("schemaFunction")== null)) {
                    PyObject obj = ((PyFunction)value).__findattr__("outputSchema");
                    if(obj != null) {
                        Utils.getSchemaFromString(obj.toString());
                    }
                    funcspec = new FuncSpec(JythonFunction.class.getCanonicalName() + "('"
                            + path + "','" + key +"')");
                    pigContext.registerFunction(namespace + key, funcspec);
                    LOG.info("Register scripting UDF: " + namespace + key);
View Full Code Here

                        }
                    }
                }
            } catch (PyException e) {
                if (e.match(Py.SystemExit)) {
                    PyObject value = e.value;
                    if (PyException.isExceptionInstance(e.value)) {
                        value = value.__findattr__("code");
                    }
                    if (new  PyInteger(0).equals(value)) {
                        LOG.info("Script invoked sys.exit(0)");
                        return;
                    }
View Full Code Here

                    Object loader = null;
                    if (value instanceof PyJavaPackage ) {
                        fileEntry = ((PyJavaPackage) value).__file__;
                    } else if (value instanceof PyObject) {
                        // resolved through the filesystem (or built-in)
                        PyObject dict = ((PyObject) value).getDict();
                        if (dict != null) {
                            fileEntry = dict.__finditem__("__file__");
                            loader = dict.__finditem__("__loader__");
                        } // else built-in
                    }   // else some system module?

                    if (fileEntry != null) {
                        File file = resolvePyModulePath(fileEntry.toString(), loader);
View Full Code Here

    private void loadData() {

        int size = this.fieldNames.__len__();
        for(int i=0; i<size; i++ ) {
            PyObject name = this.fieldNames.__getitem__(i);
            PyObject valueList = this.dataList.__getitem__(this.currentRowIndx);
            PyObject columnIndx = this.fieldNameMap.__getitem__(name);
            Integer convIndx = (Integer) columnIndx.__tojava__(Integer.class);
            //int convIndx = Integer.parseInt((String) columnIndx.__tojava__(String.class));
            PyObject value = valueList.__getitem__(convIndx);
            this.currentTest.addParam((String) name.__tojava__(String.class), (String) value.__tojava__(String.class));
        }

    }
View Full Code Here

TOP

Related Classes of org.python.core.PyObject$ConversionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.