Package org.python.pydev.jython

Examples of org.python.pydev.jython.IPythonInterpreter


    public void testJythonTests() throws Exception {
        if (RUN_TESTS_ON_SAME_PROCESS) {
            //unittest.TestCase format: the __main__ is required in the global namespace
            HashMap<String, Object> locals = new HashMap<String, Object>();
            locals.put("__name__", "__main__");
            IPythonInterpreter interpreter = JythonPlugin.newPythonInterpreter(false, false);
            ByteArrayOutputStream stdErr = new ByteArrayOutputStream();
            ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
            interpreter.setErr(stdErr);
            interpreter.setOut(stdOut);

            List<Throwable> errors = JythonPlugin.execAll(locals, "test", interpreter,
                    foldersWithTestContentsOnSameProcess, additionalPythonpathFolders);

            System.out.println(stdOut);
View Full Code Here


            this.document = document;

            //It's important that the interpreter is created in the Thread and not outside the thread (otherwise
            //it may be that the output ends up being shared, which is not what we want.)
            boolean useConsole = AnalysisPreferencesPage.useConsole();
            IPythonInterpreter interpreter = JythonPlugin.newPythonInterpreter(useConsole, false);
            if (!useConsole) {
                interpreter.setErr(NullOutputStream.singleton);
                interpreter.setOut(NullOutputStream.singleton);
            }
            String file = StringUtils.replaceAllSlashes(module.getFile().getAbsolutePath());
            interpreter.set("visitor", this);

            List<String> splitInLines = StringUtils.splitInLines(document.get());
            interpreter.set("lines", splitInLines);
            PyObject tempPep8 = pep8;
            if (tempPep8 != null) {
                interpreter.set("pep8", tempPep8);
            } else {
                interpreter.set("pep8", Py.None);
            }

            String formatted = com.aptana.shared_core.string.StringUtils.format(EXECUTE_PEP8, file, args.toString(),
                    StringUtils.replaceAllSlashes(pep8Loc.getParentFile().getAbsolutePath()), //put the parent dir of pep8.py in the pythonpath.
                    file);
            interpreter.exec(formatted);
            if (pep8 == null) {
                synchronized (lock) {
                    if (pep8 == null) {
                        pep8 = interpreter.get("pep8");
                    }
                }
            }

        } catch (Exception e) {
View Full Code Here

                                    public void run(final IProgressMonitor monitor) throws InvocationTargetException,
                                            InterruptedException {
                                        monitor.beginTask("Restoring PYTHONPATH", IProgressMonitor.UNKNOWN);

                                        IPythonInterpreter interpreter = JythonPlugin
                                                .newPythonInterpreter(false, false);
                                        interpreter.setErr(output);
                                        interpreter.setOut(output);
                                        HashMap<String, Object> locals = new HashMap<String, Object>();
                                        locals.put("api_file", filePath);
                                        locals.put("parts_for_module", d.getValue());
                                        locals.put("cancel_monitor", monitor);
                                        try {
View Full Code Here

TOP

Related Classes of org.python.pydev.jython.IPythonInterpreter

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.