Examples of IInterpreterManager


Examples of org.python.pydev.core.IInterpreterManager

        interpreter = getInterpreter(interpreterLocation, conf, pythonNature);

        //make the environment
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        envp = launchManager.getEnvironment(conf);
        IInterpreterManager manager;
        if (isJython()) {
            manager = PydevPlugin.getJythonInterpreterManager();
        } else if (isIronpython()) {
            manager = PydevPlugin.getIronpythonInterpreterManager();
        } else {
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

     * @return a tuple with the nature to be used and the name of the module represented by the file in that scenario.
     */
    public static Tuple<IPythonNature, String> getInfoForFile(File file) {

        //Check if we can resolve the manager for the passed file...
        IInterpreterManager pythonInterpreterManager2 = getPythonInterpreterManager(false);
        Tuple<IPythonNature, String> infoForManager = getInfoForManager(file, pythonInterpreterManager2);
        if (infoForManager != null) {
            return infoForManager;
        }

        IInterpreterManager jythonInterpreterManager2 = getJythonInterpreterManager(false);
        infoForManager = getInfoForManager(file, jythonInterpreterManager2);
        if (infoForManager != null) {
            return infoForManager;
        }

        IInterpreterManager ironpythonInterpreterManager2 = getIronpythonInterpreterManager(false);
        infoForManager = getInfoForManager(file, ironpythonInterpreterManager2);
        if (infoForManager != null) {
            return infoForManager;
        }

        //Ok, the file is not part of the interpreter configuration, but it's still possible that it's part of a
        //project... (external projects), so, let's go on and see if there's some match there.

        List<IPythonNature> allPythonNatures = PythonNature.getAllPythonNatures();
        int size = allPythonNatures.size();
        for (int i = 0; i < size; i++) {
            IPythonNature nature = allPythonNatures.get(i);
            try {
                //Note: only resolve in the project sources, as we've already checked the system and we'll be
                //checking all projects anyways.
                String modName = nature.resolveModuleOnlyInProjectSources(FileUtils.getFileAbsolutePath(file), true);
                if (modName != null) {
                    return new Tuple<IPythonNature, String>(nature, modName);
                }
            } catch (Exception e) {
                Log.log(e);
            }
        }

        if (pythonInterpreterManager2.isConfigured()) {
            try {
                return new Tuple<IPythonNature, String>(new SystemPythonNature(pythonInterpreterManager2),
                        getModNameFromFile(file));
            } catch (MisconfigurationException e) {
            }
        }

        if (jythonInterpreterManager2.isConfigured()) {
            try {
                return new Tuple<IPythonNature, String>(new SystemPythonNature(jythonInterpreterManager2),
                        getModNameFromFile(file));
            } catch (MisconfigurationException e) {
            }
        }

        if (ironpythonInterpreterManager2.isConfigured()) {
            try {
                return new Tuple<IPythonNature, String>(new SystemPythonNature(ironpythonInterpreterManager2),
                        getModNameFromFile(file));
            } catch (MisconfigurationException e) {
            }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

            ArrayList<ICompletionProposal> pythonAndTemplateProposals = new ArrayList<ICompletionProposal>();

            IPythonNature nature = edit.getPythonNature();

            if (nature == null) {
                IInterpreterManager manager = ChooseInterpreterManager.chooseInterpreterManager();
                if (manager != null) {
                    nature = new SystemPythonNature(manager);
                } else {
                    CompletionError completionError = new CompletionError(new RuntimeException(
                            "No interpreter configured."));
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

                        if (!source.getSelection()) {
                            return; //we'll get 2 notifications: selection of one and deselection of the other, so, let's just treat the selection
                        }
                    }

                    IInterpreterManager interpreterManager;

                    if (radioJy.getSelection()) {
                        interpreterManager = PydevPlugin.getJythonInterpreterManager();

                    } else if (radioIron.getSelection()) {
                        interpreterManager = PydevPlugin.getIronpythonInterpreterManager();

                    } else {
                        interpreterManager = PydevPlugin.getPythonInterpreterManager();
                    }

                    IInterpreterInfo[] interpretersInfo = interpreterManager.getInterpreterInfos();
                    if (interpretersInfo.length > 0) {
                        ArrayList<String> interpretersWithDefault = new ArrayList<String>();
                        interpretersWithDefault.add(IPythonNature.DEFAULT_INTERPRETER);
                        for (IInterpreterInfo info : interpretersInfo) {
                            interpretersWithDefault.add(info.getName());
                        }
                        interpretersChoice.setItems(interpretersWithDefault.toArray(new String[0]));

                        interpretersChoice.setVisible(true);
                        interpreterNoteText.setText("<a>Click here to configure an interpreter not listed.</a>");
                        interpretersChoice.setText(IPythonNature.DEFAULT_INTERPRETER);

                    } else {
                        interpretersChoice.setVisible(false);
                        interpreterNoteText.setText(INTERPRETER_NOT_CONFIGURED_MSG);

                    }
                    //config which preferences page should be opened!
                    switch (interpreterManager.getInterpreterType()) {
                        case IInterpreterManager.INTERPRETER_TYPE_PYTHON:
                            idToConfig[0] = "org.python.pydev.ui.pythonpathconf.interpreterPreferencesPagePython";
                            break;

                        case IInterpreterManager.INTERPRETER_TYPE_JYTHON:
                            idToConfig[0] = "org.python.pydev.ui.pythonpathconf.interpreterPreferencesPageJython";
                            break;

                        case IInterpreterManager.INTERPRETER_TYPE_IRONPYTHON:
                            idToConfig[0] = "org.python.pydev.ui.pythonpathconf.interpreterPreferencesPageIronpython";
                            break;

                        default:
                            throw new RuntimeException("Cannot recognize type: "
                                    + interpreterManager.getInterpreterType());

                    }
                    if (onSelectionChanged != null) {
                        try {
                            onSelectionChanged.call(null);
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

     */
    private PythonRunnerConfig getConfig(ILaunchConfiguration configuration,
            ILaunchConfigurationDialog launchConfigurationDialog) throws CoreException, InvalidRunException,
            MisconfigurationException {
        String run;
        IInterpreterManager interpreterManager = getInterpreterManager();
        if (interpreterManager == null) {
            return null;
        }
        switch (interpreterManager.getInterpreterType()) {
            case IInterpreterManager.INTERPRETER_TYPE_JYTHON:
                run = PythonRunnerConfig.RUN_JYTHON;
                break;

            case IInterpreterManager.INTERPRETER_TYPE_IRONPYTHON:
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

            fWorkingCopyForCommandLineGeneration = configuration.getWorkingCopy();
        } catch (CoreException e1) {
            throw new RuntimeException(e1);
        }

        IInterpreterManager interpreterManager = this.getInterpreterManager();
        String[] interpreterNames = new String[0];
        if (interpreterManager != null) {
            IInterpreterInfo[] interpreterInfos = interpreterManager.getInterpreterInfos();
            if (interpreterInfos.length > 0) {
                // There is at least one interpreter defined, add the default interpreter option at the beginning.
                interpreterNames = new String[interpreterInfos.length + 1];
                interpreterNames[0] = InterpreterTab.DEFAULT_INTERPRETER_NAME;

                for (int i = 0; i < interpreterInfos.length; i++) {
                    interpreterNames[i + 1] = interpreterInfos[i].getName();
                }
            }
        }
        fInterpreterComboField.setItems(interpreterNames);

        String interpreter = "";
        try {
            interpreter = configuration.getAttribute(Constants.ATTR_INTERPRETER, Constants.ATTR_INTERPRETER_DEFAULT);
        } catch (CoreException e) {
        }

        if (fInterpreterComboField.getItems().length == 0) {
            setErrorMessage("No interpreter is configured, please, go to window > preferences > interpreters and add the interpreter you want to use.");

        } else {

            int selectThis = -1;

            if (interpreter.equals(Constants.ATTR_INTERPRETER_DEFAULT)) {
                selectThis = 0;
            } else {
                if (interpreterManager != null) {
                    IInterpreterInfo[] interpreterInfos = interpreterManager.getInterpreterInfos();
                    for (int i = 0; i < interpreterInfos.length; i++) {
                        if (interpreterInfos[i].matchNameBackwardCompatible(interpreter)) {
                            selectThis = i + 1; //Internally, it's the index+1 (because the one at 0 is the default)
                            break;
                        }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

     * @param interpreter the interpreter to validate
     * @return true if the interpreter is configured in pydev
     * @throws MisconfigurationException
     */
    protected boolean checkIfInterpreterExists(String interpreter) throws MisconfigurationException {
        IInterpreterManager interpreterManager = this.getInterpreterManager();
        if (interpreterManager == null) {
            return false;
        }
        if (interpreter.equals(Constants.ATTR_INTERPRETER_DEFAULT)) {
            if (interpreterManager.getDefaultInterpreterInfo(false) != null) {
                // The default interpreter is selected, and we have a default interpreter
                return true;
            }
            //otherwise, the default is selected, but we have no default
            return false;
        }

        IInterpreterInfo[] interpreters = interpreterManager.getInterpreterInfos();
        for (int i = 0; i < interpreters.length; i++) {
            if (interpreters[i] != null && interpreters[i].matchNameBackwardCompatible(interpreter)) {
                return true;
            }
        }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager


public class InterpreterTypeTester extends PropertyTester {

    public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
        IInterpreterManager interpreterManager = null;
        String str = expectedValue.toString();

        if ("python".equals(str)) {
            interpreterManager = PydevPlugin.getPythonInterpreterManager();
        } else if ("jython".equals(str)) {
            interpreterManager = PydevPlugin.getJythonInterpreterManager();
        } else if ("ironpython".equals(str)) {
            interpreterManager = PydevPlugin.getIronpythonInterpreterManager();
        } else {
            Log.log("Unable to check for: " + expectedValue);
        }

        if (interpreterManager != null) {
            try {
                String defaultInterpreter = interpreterManager.getDefaultInterpreterInfo(false).getExecutableOrJar();
                return defaultInterpreter != null;
            } catch (MisconfigurationException e) {
                return false;
            }
        }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

        }

        String[] parameters = SimplePythonRunner.preparePythonCallParameters(interpreter.getExecutableOrJar(),
                FileUtils.getFileAbsolutePath(serverFile), new String[] { "" + pWrite, "" + pRead });

        IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager();

        String[] envp = null;
        try {
            envp = SimpleRunner.getEnvironment(null, interpreter, manager);
        } catch (CoreException e) {
View Full Code Here

Examples of org.python.pydev.core.IInterpreterManager

            throws IOException, JDTNotAvailableException, MisconfigurationException {
        String script = FileUtils.getFileAbsolutePath(serverFile);
        String[] executableStr = SimpleJythonRunner.makeExecutableCommandStr(jythonJar.getExecutableOrJar(), script,
                "", String.valueOf(pWrite), String.valueOf(pRead));

        IInterpreterManager manager = PydevPlugin.getJythonInterpreterManager();

        String[] envp = null;
        try {
            envp = SimpleRunner.getEnvironment(null, jythonJar, manager);
        } catch (CoreException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.