Package org.python.core

Examples of org.python.core.PyObject$ConversionException


      checkArgument(interfaceClass.isAssignableFrom(langType.getJavaClass()),
          langType.getJavaClass().getSimpleName() + " needs to implement " +
          interfaceClass.getSimpleName());
      break;
    case JYTHON:
      PyObject pyClass = interpreter.get(langType.getJythonClassName());
      PyObject pyObj = pyClass.__call__();
      Object converted = pyObj.__tojava__(interfaceClass);
      checkArgument(!Py.NoConversion.equals(converted),
         "Jython class " + langType.getJythonClassName() +
         " does not implement " + interfaceClass.getSimpleName() +
         " interface");
      break;
View Full Code Here


   * @param interpreter PythonInterpreter
   * @return language and type specification
   */
  private static LanguageAndType processJythonType(String jythonName,
      PythonInterpreter interpreter) {
    PyObject pyClass = interpreter.get(jythonName);
    checkNotNull(pyClass, "Jython class " + jythonName + " not found");
    return LanguageAndType.jython(jythonName);
  }
View Full Code Here

   */
  public static <T extends Writable> JythonColumnReader<T>
  create(ImmutableClassesGiraphConfiguration conf,
      StrConfOption jythonClassOption, StrConfOption columnOption,
      HiveTableSchema schema) {
    PyObject pyClass =
        JythonUtils.getInterpreter().get(jythonClassOption.get(conf));
    JythonHiveReader jythonHiveReader = (JythonHiveReader)
        pyClass.__call__().__tojava__(JythonHiveReader.class);
    int columnIndex = HiveUtils.columnIndexOrThrow(schema, conf, columnOption);
    return new JythonColumnReader<T>(columnIndex, jythonHiveReader);
  }
View Full Code Here

            }
          }
        }
        PythonInterpreter interp = new PythonInterpreter(null, state);
        interp.exec(strScript);
        PyObject getInstance = interp.get("getInstance");
        if (!(getInstance instanceof PyFunction)) {
          throw new ScriptCompilationException("\"getInstance\" is not a function.");
        }
        PyObject _this;
        if (arguments == null) {
          _this = ((PyFunction) getInstance).__call__();
        } else {
          PyObject[] args = new PyObject[arguments.length];
          for (int i=0; i<arguments.length; i++) {
            args[i] = new PyJavaInstance(arguments[i]);
          }
          _this = ((PyFunction) getInstance).__call__(args);
        }
        return _this.__tojava__(scriptInterfaces[0]);
      } catch (Exception ex) {
        logger.error("Error while loading script.", ex);
        if (ex instanceof IOException) {
          // Raise to caller
          throw (IOException) ex;
View Full Code Here

     */
    public TemplateCollectionModel keys() throws TemplateModelException
    {
        try
        {
            PyObject method = object.__findattr__(KEYS);
            if(method == null)
            {
                method = object.__findattr__(KEYSET);
            }
            if(method != null)
            {
                return (TemplateCollectionModel)wrapper.wrap(method.__call__());
            }
        }
        catch(PyException e)
        {
            throw new TemplateModelException(e);
View Full Code Here

     */
    public TemplateCollectionModel values() throws TemplateModelException
    {
        try
        {
            PyObject method = object.__findattr__(VALUES);
            if(method != null)
            {
                return (TemplateCollectionModel)wrapper.wrap(method.__call__());
            }
        }
        catch(PyException e)
        {
            throw new TemplateModelException(e);
View Full Code Here

        if(key != null)
        {
            key = key.intern();
        }
       
        PyObject obj = null;
       
        try
        {
            if(wrapper.isAttributesShadowItems())
            {
View Full Code Here

        }

        private void interpretBuffer() {
          Environment env = Environment.getCurrentEnvironment();
            synchronized(JythonRuntime.this) {
                PyObject prevOut = systemState.stdout;
                try {
                    setOut(out);
                    set("env", env);
                    exec(buf.toString());
                    buf.setLength(0);
View Full Code Here

        try {
            f = JythonScriptEngine.getFunction(filename, functionName);
            this.function = f;
            num_parameters = ((PyBaseCode) f.func_code).co_argcount;
            PyObject outputSchemaDef = f.__findattr__("outputSchema".intern());
            if (outputSchemaDef != null) {
                this.schema = Utils.getSchemaFromString(outputSchemaDef.toString());
                found = true;
            }
            PyObject outputSchemaFunctionDef = f.__findattr__("outputSchemaFunction".intern());
            if (outputSchemaFunctionDef != null) {
                if(found) {
                    throw new ExecException(
                            "multiple decorators for " + functionName);
                }
                scriptFilePath = filename;
                outputSchemaFunc = outputSchemaFunctionDef.toString();
                this.schema = null;
                found = true;
            }
            PyObject schemaFunctionDef = f.__findattr__("schemaFunction".intern());
            if (schemaFunctionDef != null) {
                if(found) {
                    throw new ExecException(
                            "multiple decorators for " + functionName);
                }
View Full Code Here

    @Override
    public Object exec(Tuple tuple) throws IOException {
        try {
            if (tuple == null || num_parameters == 0) {
                // ignore input tuple
                PyObject out = function.__call__();
                return JythonUtils.pythonToPig(out);
            }
            else {
                // this way we get the elements of the tuple as parameters instead
                // of one tuple object
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.