[python.core] Fixed env variable access at PythonAutoDetector
authorJulio C. Rocha <juniel_katarn@netbeans.org>
Sun, 10 May 2015 23:44:07 -0700
changeset 18269aa006f2ab6a9
parent 18268 37c303fe9257
child 18270 d1679e74e1cb
child 18273 7268510f9338
[python.core] Fixed env variable access at PythonAutoDetector
python.core/src/org/netbeans/modules/python/api/PythonAutoDetector.java
python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java
     1.1 --- a/python.core/src/org/netbeans/modules/python/api/PythonAutoDetector.java	Fri May 08 22:17:50 2015 -0500
     1.2 +++ b/python.core/src/org/netbeans/modules/python/api/PythonAutoDetector.java	Sun May 10 23:44:07 2015 -0700
     1.3 @@ -44,7 +44,6 @@
     1.4  
     1.5  import java.io.File;
     1.6  import java.util.ArrayList;
     1.7 -import java.util.Iterator;
     1.8  import java.util.logging.Level;
     1.9  import java.util.logging.Logger;
    1.10  import org.openide.util.Exceptions;
    1.11 @@ -56,19 +55,19 @@
    1.12   * @author Lou Dasaro <mr_lou_d@netbeans.org>
    1.13   */
    1.14  public class PythonAutoDetector {
    1.15 -    private Logger LOGGER = Logger.getLogger(PythonAutoDetector.class.getName());
    1.16 +    private static final Logger LOGGER = Logger.getLogger(PythonAutoDetector.class.getName());
    1.17  
    1.18 -    private ArrayList<String> matches = new ArrayList<>();
    1.19 +    private final ArrayList<String> matches = new ArrayList<>();
    1.20      boolean searchNestedDirectoies = true;
    1.21  
    1.22      private void processAction(File dir) {
    1.23          if (LOGGER.isLoggable(Level.FINE)) {
    1.24 -            LOGGER.log(Level.FINE, "Inspecting: " + dir.getAbsolutePath());
    1.25 +            LOGGER.log(Level.FINE, "Inspecting: {0}", dir.getAbsolutePath());
    1.26          }
    1.27          if(dir.isFile()){
    1.28              int pos = dir.getName().indexOf(".");
    1.29 -            String name = null;
    1.30 -            String ext = null;
    1.31 +            String name;
    1.32 +            String ext;
    1.33              if (pos > -1 ){
    1.34                   name = dir.getName().substring(0, pos);
    1.35                   ext = dir.getName().substring(pos+1);
    1.36 @@ -147,10 +146,11 @@
    1.37      }
    1.38      
    1.39      public void traverseEnvPaths() throws SecurityException{
    1.40 -        String delims = "[;]"; // might not be correct for some *nix implementations ???
    1.41 -        String sEnvPath = "";
    1.42 +        String delims = "[" + System.getProperty("path.separator") + "]";
    1.43 +        String sEnvPath;
    1.44          try{
    1.45 -            sEnvPath = System.getenv("path");
    1.46 +            // Env variables must be upper-case in Unix. Windows is case-insensitive.
    1.47 +            sEnvPath = System.getenv("PATH");
    1.48          } catch (SecurityException se) {
    1.49              Exceptions.printStackTrace(se);
    1.50              return;
    1.51 @@ -159,7 +159,7 @@
    1.52          String[] paths = sEnvPath.split(delims);
    1.53          int iCount = countMatches();
    1.54          // search ONLY paths that contain the substring python/jython
    1.55 -        for( String spath: paths) { 
    1.56 +        for(String spath: paths) { 
    1.57              if( spath.toLowerCase().contains("jython") ||
    1.58                  spath.toLowerCase().contains("python") ){
    1.59                  searchNestedDirectoies = true;
     2.1 --- a/python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java	Fri May 08 22:17:50 2015 -0500
     2.2 +++ b/python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java	Sun May 10 23:44:07 2015 -0700
     2.3 @@ -8,7 +8,6 @@
     2.4  import java.io.IOException;
     2.5  import java.io.Serializable;
     2.6  import java.util.ArrayList;
     2.7 -import java.util.Arrays;
     2.8  import java.util.Collections;
     2.9  import java.util.HashMap;
    2.10  import java.util.List;