Package org.python.util

Examples of org.python.util.PythonInterpreter


            out.write(b);
        }
    }

    private void loadScript(Writer out, Writer err) {
        interpreter = new PythonInterpreter();
        interpreter.setOut(new WriterOutputStream(out));
        interpreter.setErr(new WriterOutputStream(err));
        try {
            clearModuleDefinitions();
            interpreterExec("import __builtin__");
View Full Code Here


    private PythonInterpreter createPythonInterpreter() throws IOException {
        Properties props = System.getProperties();
        // String moduleDirs = getConcatenatedStringFromArray(moduleDir, ';');
        props.setProperty("python.path", (new File(testDirectory)).getCanonicalPath());
        PythonInterpreter.initialize(System.getProperties(), props, new String[] { "" });
        return new PythonInterpreter();
    }
View Full Code Here

        updateInitForDirectory(directory.getParentFile(), projectHome);
    }

    public static PythonInterpreter getInterpreter() {
        if (interpreter == null)
            interpreter = new PythonInterpreter();
        return interpreter;
    }
View Full Code Here

            })) {
              state.path.insert(1, Py.newString(basePath + "lib" + File.separator + filename));
            }
          }
        }
        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) {
View Full Code Here

    public void registerFunctions(String path, String namespace, PigContext pigContext)
    throws IOException {
        Interpreter.setMain(false);
        Interpreter.init(path, pigContext);
        pigContext.scriptJars.add(getJarPath(PythonInterpreter.class));
        PythonInterpreter pi = Interpreter.interpreter;
        @SuppressWarnings("unchecked")
        List<PyTuple> locals = ((PyStringMap) pi.getLocals()).items();
        namespace = (namespace == null) ? "" : namespace + NAMESPACE_SEPARATOR;
        try {
            for (PyTuple item : locals) {
                String key = (String) item.get(0);
                Object value = item.get(1);
View Full Code Here

        this.indicators = context.getIndicators();
        this.userInterface = context.getUserInterface();
        this.moduleWatcher = new ModuleWatcher(pythonModulePath, this);
        this.moduleWatcher.start();

        this.python = new PythonInterpreter();
        this.python.setErr(java.lang.System.out);
        reloadPythonModule();
    }
View Full Code Here

    args = HiveJythonUtils.processArgs(args, CONF);
    LOG.info("Processed hive options now have args: " + Arrays.toString(args));

    HiveIO.init(CONF, false);

    PythonInterpreter interpreter = new PythonInterpreter();

    JythonJob jythonJob = parseJythonFiles(interpreter, args);

    logOptions();
View Full Code Here

        String binding = getJythonBinding();
        String testRoot = getJythonTestRoot();
        String xmlReportFile = getOptionalXmlReportFilename();
        String ignoreFile = getOptionalIgnoreFile();

        PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile, ignoreFile);
        interp.getSystemState().path.insert(0, new PyString(binding));
        interp.getSystemState().path.insert(0, new PyString(testRoot));

        LOGGER.info("About to call Jython test script: '" + testScript
                + "' with '" + testRoot + "' added to Jython path");

        int maxInvocations = Integer.getInteger(TEST_INVOCATIONS_SYSTEM_PROPERTY, 1);
View Full Code Here

        if(Boolean.getBoolean(ALWAYS_COLORIZE_SYSTEM_PROPERTY))
        {
            systemState.argv.append(new PyString("--always-colorize"));
        }

        PythonInterpreter interp = new PythonInterpreter(null, systemState);
        return interp;
    }
View Full Code Here

            properties.setProperty("python.home", workDir.toString());
            properties.setProperty("python.packages.fakepath",
                    (String)avalonContext.get(Constants.CONTEXT_CLASSPATH));
            PythonInterpreter.initialize(System.getProperties(), properties, new String[]{});

            python = new PythonInterpreter();
            python.set("page", this);
            python.set("logger", getLogger());
            python.set("xspAttr", new AttributesImpl());
       
            if (getLogger().isDebugEnabled()) {
View Full Code Here

TOP

Related Classes of org.python.util.PythonInterpreter

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.