Package org.python.pydev.runners.UniversalRunner

Examples of org.python.pydev.runners.UniversalRunner.AbstractRunner


            PythonNature nature = PythonNature.getPythonNature(container);
            if (nature == null) {
                throw new RuntimeException("The directory passed: " + container
                        + " does not have an associated nature.");
            }
            AbstractRunner runner = UniversalRunner.getRunner(nature);

            //First, combine the results of the many runs we may have.
            Tuple<String, String> output = runner.runScriptAndGetOutput(PythonRunnerConfig.getCoverageScript(),
                    new String[] { "combine" }, getCoverageDirLocation(), monitor);

            if (output.o1 != null && output.o1.length() > 0) {
                Log.logInfo(output.o1);
            }
            if (output.o2 != null && output.o2.length() > 0) {
                if (output.o2.startsWith("Coverage.py warning:")) {
                    Log.logInfo(output.o2);

                } else {
                    Log.log(output.o2);
                }
            }

            //we have to make a process to execute the script. it should look
            // like:
            //coverage.py -r [-m] FILE1 FILE2 ...
            //Report on the statement coverage for the given files. With the -m
            //option, show line numbers of the statements that weren't
            // executed.

            //python coverage.py -r -m files....

            monitor.setTaskName("Starting shell to get info...");
            monitor.worked(1);
            Process p = null;

            try {
                //                Tuple<Process, String> tup = runner.createProcess(
                //                        PythonRunnerConfig.getCoverageScript(), new String[]{
                //                            "-r", "-m", "--include", ".*"}, getCoverageDirLocation(), monitor);
                Tuple<Process, String> tup = runner.createProcess(PythonRunnerConfig.getCoverageScript(),
                        new String[] { "--pydev-analyze" }, getCoverageDirLocation(), monitor);
                p = tup.o1;
                try {
                    p.exitValue();
                    throw new RuntimeException("Some error happened... the process could not be created.");
View Full Code Here


            message.setMessage("This action can only be applied in a project that is configured as a Pydev project.");
            message.open();
            return false;
        }

        AbstractRunner runner = UniversalRunner.getRunner(nature);

        Tuple<String, String> tup = runner.runCodeAndGetOutput(RUN_2_TO_3_CODE, new String[] { "--help" }, null,
                new NullProgressMonitor());
        if (tup.o1.indexOf("ImportError") != -1 || tup.o2.indexOf("ImportError") != -1) {
            MessageBox message = new MessageBox(PyAction.getShell(), SWT.OK | SWT.ICON_ERROR);
            message.setText("Unable to run 2to3");
            message.setMessage("Unable to run 2to3. Details: \n" + tup.o1 + "\n" + tup.o2
View Full Code Here

        parameters = null;
    }

    protected int doActionOnResource(IResource next, IProgressMonitor monitor) {
        this.refresh = new ArrayList<IContainer>();
        AbstractRunner runner = UniversalRunner.getRunner(natureUsed);
        if (next instanceof IContainer) {
            this.refresh.add((IContainer) next);
        } else {
            this.refresh.add(next.getParent());
        }

        String dir = next.getLocation().toOSString();
        File workingDir = new File(dir);
        if (!workingDir.exists()) {
            Log.log("Received file that does not exist for 2to3: " + workingDir);
            return 0;
        }
        if (!workingDir.isDirectory()) {
            workingDir = workingDir.getParentFile();
            if (!workingDir.isDirectory()) {
                Log.log("Unable to find working dir for 2to3. Found invalid: " + workingDir);
                return 0;
            }
        }
        ArrayList<String> parametersWithResource = new ArrayList<String>(parameters);
        parametersWithResource.add(0, dir);
        Tuple<String, String> tup = runner.runCodeAndGetOutput(RUN_2_TO_3_CODE,
                parametersWithResource.toArray(new String[0]), workingDir, monitor);
        IOConsoleOutputStream out = MessageConsoles.getConsoleOutputStream("2To3", UIConstants.PY_INTERPRETER_ICON);
        try {
            out.write(tup.o1);
            out.write("\n");
View Full Code Here

            } else {
                interpreterInfo = interpreterManagerFromType.getInterpreterInfo(projectInterpreter, null);

            }
            nature = new SystemPythonNature(interpreterManagerFromType, interpreterInfo);
            AbstractRunner runner = UniversalRunner.getRunner(nature);

            Tuple<String, String> output = runner.runCodeAndGetOutput(GET_DJANGO_VERSION, new String[] {}, null,
                    new NullProgressMonitor());

            String err = output.o2.trim();
            String out = output.o1.trim();
            if (err.length() > 0) {
View Full Code Here

            if (astManager == null) {
                throw new RuntimeException(
                        "Error creating Django project. ASTManager not available after 10 seconds.\n"
                                + "Please report this bug at the sourceforge tracker.");
            }
            AbstractRunner runner = UniversalRunner.getRunner(nature);

            IContainer projectContainer;

            switch (sourceFolderConfigurationStyle) {
                case IWizardNewProjectNameAndLocationPage.PYDEV_NEW_PROJECT_CREATE_PROJECT_AS_SRC_FOLDER:
                case IWizardNewProjectNameAndLocationPage.PYDEV_NEW_PROJECT_NO_PYTHONPATH:
                    projectContainer = projectHandle;
                    break;
                default:
                    projectContainer = projectHandle.getFolder("src");
            }

            String projectName = projectHandle.getName();
            Tuple<String, String> output = runner.runCodeAndGetOutput(RUN_DJANGO_ADMIN, new String[] { "startproject",
                    projectName }, projectContainer.getLocation().toFile(), new NullProgressMonitor());

            if (output.o2.indexOf("ImportError: no module named django") != -1) {
                RunInUiThread.async(new Runnable() {
View Full Code Here

        CompiledModule.COMPILED_MODULES_ENABLED = false;
        super.tearDown();
    }

    public void testUniversalRunnerWithJython() throws Exception {
        AbstractRunner runner = UniversalRunner.getRunner(nature);
        assertEquals(nature.getInterpreterType(), IPythonNature.INTERPRETER_TYPE_JYTHON);
        Tuple<String, String> output = runner.runCodeAndGetOutput(
                "import sys\nprint 'test'\nprint >> sys.stderr, 'err'", null, null, new NullProgressMonitor());
        assertEquals("test", output.o1.trim());
        assertEquals("err", output.o2.trim());

        Tuple<Process, String> createProcess = runner.createProcess(TestDependent.TEST_PYSRC_LOC
                + "universal_runner_test.py", null, null, new NullProgressMonitor());
        output = SimpleRunner.getProcessOutput(createProcess.o1, "", new NullProgressMonitor(), "utf-8");
        assertEquals("stdout", output.o1.trim());
        assertEquals("stderr", output.o2.trim());
    }
View Full Code Here

        CompiledModule.COMPILED_MODULES_ENABLED = false;
        super.tearDown();
    }

    public void testUniversalRunnerWithJython() throws Exception {
        AbstractRunner runner = UniversalRunner.getRunner(nature);
        assertEquals(nature.getInterpreterType(), IPythonNature.INTERPRETER_TYPE_PYTHON);
        Tuple<String, String> output = runner.runCodeAndGetOutput(
                "import sys\nprint 'test'\nprint >> sys.stderr, 'err'", null, null, new NullProgressMonitor());
        assertEquals("test", output.o1.trim());
        assertEquals("err", output.o2.trim());

        Tuple<Process, String> createProcess = runner.createProcess(TestDependent.TEST_PYSRC_LOC
                + "universal_runner_test.py", null, null, new NullProgressMonitor());
        output = SimpleRunner.getProcessOutput(createProcess.o1, "", new NullProgressMonitor(), "utf-8");
        assertEquals("stdout", output.o1.trim());
        assertEquals("stderr", output.o2.trim());
    }
View Full Code Here

    public static void main(String[] args) {
        junit.textui.TestRunner.run(IronPythonUniversalRunnerTest.class);
    }

    public void testUniversalRunnerWithIronPython() throws Exception {
        AbstractRunner runner = UniversalRunner.getRunner(nature);
        assertEquals(nature.getInterpreterType(), IPythonNature.INTERPRETER_TYPE_IRONPYTHON);
        Tuple<String, String> output = runner.runCodeAndGetOutput(
                "import sys\nprint 'test'\nprint >> sys.stderr, 'err'", null, null, new NullProgressMonitor());
        assertEquals("test", output.o1.trim());
        assertEquals("err", output.o2.trim());

        Tuple<Process, String> createProcess = runner.createProcess(TestDependent.TEST_PYSRC_LOC
                + "universal_runner_test.py", null, null, new NullProgressMonitor());
        output = SimpleRunner.getProcessOutput(createProcess.o1, "", new NullProgressMonitor(), "utf-8");
        assertEquals("stdout", output.o1.trim());
        assertEquals("stderr", output.o2.trim());
View Full Code Here

            String[] arguments = new String[0];
            if (cmdLineArguments.length() > 0) {
                arguments = PythonRunnerConfig.parseStringIntoList(cmdLineArguments);
            }

            AbstractRunner universalRunner = UniversalRunner.getRunner(pythonPathNature.getNature());
            Tuple<Process, String> run = universalRunner.createProcess(appcfg.getAbsolutePath(), arguments,
                    appEngineLocation, new NullProgressMonitor());

            process = run.o1;
            if (process != null) {
View Full Code Here

      }
    } catch (MisconfigurationException e) {
      Log.log(e);
      return null;
    }
    AbstractRunner runner = UniversalRunner.getRunner(nature);
    ArrayList<String> argumentList = new ArrayList<String>();
    if (bounds != null) {
      argumentList.add("-c");
      argumentList.add("-x");
      argumentList.add(Integer.toString(bounds.width));
      argumentList.add("-y");
      argumentList.add(Integer.toString(bounds.height));
    }
    String[] arguments =
        (String[])argumentList.toArray(new String[argumentList.size()]);
    File editorFile = pyEdit.getEditorFile();
    Tuple<Process, String> tuple = runner.createProcess(
        FileUtils.getFileAbsolutePath(scriptPath),
        arguments,
        editorFile.getParentFile(),
        null);
    if(tuple.o1 != null){
View Full Code Here

TOP

Related Classes of org.python.pydev.runners.UniversalRunner.AbstractRunner

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.