Examples of IInterpreterInfo


Examples of org.python.pydev.core.IInterpreterInfo

    if (nature == null){
      throw new RuntimeException(
          Services.getMessage("python.missing.nature"));
    }

    IInterpreterInfo interpreter = null;
    IInterpreterManager manager = nature.getRelatedInterpreterManager();
    IInterpreterInfo[] existing = manager.getInterpreterInfos();
    for (IInterpreterInfo info : existing){
      if (info.getName().equals(interpreterNameOrPath) ||
          info.getExecutableOrJar().equals(interpreterNameOrPath))
      {
        interpreter = info;
        break;
      }
    }

    File path = new File(interpreterNameOrPath);
    if (interpreter == null && path.exists() && path.isFile()){
      HashSet<String> skip = new HashSet<String>();
      for (IInterpreterInfo info : existing){
        skip.add(info.getExecutableOrJar());
      }
      interpreter = manager.createInterpreterInfo(
          interpreterNameOrPath, new NullProgressMonitor(), false);
      interpreter.setName(FileUtils.getBaseName(interpreterNameOrPath));
      IInterpreterInfo[] updated = new IInterpreterInfo[existing.length + 1];
      System.arraycopy(existing, 0, updated, 0, existing.length);
      updated[updated.length - 1] = interpreter;
      manager.setInfos(updated, skip, new NullProgressMonitor());
    }else if (interpreter == null){
      throw new RuntimeException(Services.getMessage(
            "python.interpreter.not.found", interpreterNameOrPath));
    }

    if (version == null){
      version = nature.getVersion();
    }

    // ensure the version is valid for the new interpreter
    ArrayList<String> grammars = new ArrayList<String>();
    String[] parts = StringUtils.split(interpreter.getVersion(), ".");
    double iversion = Double.parseDouble(parts[0] + '.' + parts[1]);
    for (String grammar : IPythonNature.Versions.ALL_PYTHON_VERSIONS){
      grammar = grammar.replace("python ", "");
      double gversion = Double.parseDouble(grammar);
      if (gversion <= iversion &&
          grammar.charAt(0) == interpreter.getVersion().charAt(0))
      {
        grammars.add(grammar);
      }
    }
    if (!grammars.contains(version)){
      Collections.sort(grammars);
      version = grammars.get(grammars.size() - 1);
    }

    nature.setVersion(version, interpreter.getName());

    return Services.getMessage("python.interpreter.set", projectName);
  }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

    String projectName = commandLine.getValue(Options.PROJECT_OPTION);
    IProject project = ProjectUtils.getProject(projectName);
    PythonNature nature = PythonNature.getPythonNature(project);
    ArrayList<String> grammars = new ArrayList<String>();
    if (nature != null){
      IInterpreterInfo interpreter = nature.getProjectInterpreter();
      if (interpreter != null){
        String version = interpreter.getVersion();
        String[] parts = StringUtils.split(version, ".");
        double iversion = Double.parseDouble(parts[0] + '.' + parts[1]);
        for (String grammar : IPythonNature.Versions.ALL_PYTHON_VERSIONS){
          grammar = grammar.replace("python ", "");
          double gversion = Double.parseDouble(grammar);
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

    throws Exception
  {
    String projectName = commandLine.getValue(Options.PROJECT_OPTION);
    IProject project = ProjectUtils.getProject(projectName);
    PythonNature nature = PythonNature.getPythonNature(project);
    IInterpreterInfo interpreter = nature.getProjectInterpreter();
    if (interpreter != null){
      return interpreter.getExecutableOrJar();
    }
    return null;
  }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

    project.setDescription(desc, new NullProgressMonitor());

    String pythonPath = project.getFullPath().toString();
    String interpreter = cli.getOptionValue("interpreter");
    IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager();
    IInterpreterInfo info = manager.getInterpreterInfo(interpreter, null);
    if (info == null){
      throw new RuntimeException("Python interpreter not found: " + interpreter);
    }

    // construct version from the interpreter chosen.
    String version = "python " +
      IGrammarVersionProvider.grammarVersionToRep.get(info.getGrammarVersion());

    // see src.org.python.pydev.plugin.PyStructureConfigHelpers
    PythonNature.addNature(
        project, null, version, pythonPath, null, interpreter, null);
  }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

    /**
     * Creates the jython interpreter manager with the default jython jar location.
     */
    protected static void createJythonInterpreterManager(NullProgressMonitor monitor) {
        IInterpreterManager iMan = PydevPlugin.getJythonInterpreterManager(true);
        IInterpreterInfo interpreterInfo = iMan
                .createInterpreterInfo(TestDependent.JYTHON_JAR_LOCATION, monitor, false);
        iMan.setInfos(new IInterpreterInfo[] { interpreterInfo }, null, null);
    }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

    /**
     * Creates the python interpreter manager with the default jython jar location.
     */
    protected static void createPythonInterpreterManager(NullProgressMonitor monitor) {
        IInterpreterManager iMan = PydevPlugin.getPythonInterpreterManager(true);
        IInterpreterInfo interpreterInfo = iMan.createInterpreterInfo(TestDependent.PYTHON_EXE, monitor, false);
        iMan.setInfos(new IInterpreterInfo[] { interpreterInfo }, null, null);
    }
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

    public static PydevConsoleInterpreter createPydevInterpreter(PydevConsoleLaunchInfo info,
            List<IPythonNature> natures) throws Exception {
        final ILaunch launch = info.launch;
        Process process = info.process;
        Integer clientPort = info.clientPort;
        IInterpreterInfo interpreterInfo = info.interpreter;
        if (launch == null) {
            return null;
        }

        PydevConsoleInterpreter consoleInterpreter = new PydevConsoleInterpreter();
View Full Code Here

Examples of org.python.pydev.core.IInterpreterInfo

            if (interpreters == null || interpreters.length == 0) {
                MessageDialog.openError(workbenchWindow.getShell(), "No interpreters for creating console",
                        "No interpreter available for creating a console.");
                return null;
            }
            IInterpreterInfo interpreter = null;
            if (interpreters.length == 1) {
                //We just have one, so, no point in asking about which one should be there.
                interpreter = interpreters[0];
            }
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.