Ignore:
Timestamp:
2017-08-11T17:07:44+12:00 (7 years ago)
Author:
ak19
Message:

Getting Windows wget to use proxy settings in environment. They didn't need to be in CAPS, as Windows has the side effect of setting env vars in both the original case of the letters of the env variable name as well as in all caps, and unsetting either version unsets both. On Windows however, I noticed that Perl was not on the PATH after open3() in WgetDownload.pm::useWget() failed with an unclear error message. So now the PATH is also propagated from Java to the perl code for downloading using wget.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/download/ServerInfoDialog.java

    r31860 r31877  
    104104    String[] command = (String[]) commands.toArray(new String[0]);
    105105    DebugStream.println("Getting server info: "+commands);
    106     try {
    107         String [] env = null;
     106    try {       
    108107        SafeProcess prcs = null;
    109108       
    110         if (Utility.isWindows()) {
    111         prcs = new SafeProcess(command);
    112         }
    113         else {
    114         if (proxy_url != null && !proxy_url.equals("")) {           
     109        if (proxy_url != null && !proxy_url.equals("")) {
    115110            // Specify proxies as environment variables
    116111            // Need to manually specify GSDLHOME and GSDLOS also
    117             env = new String[6];
    118                     proxy_url = proxy_url.replaceAll("http://","");
    119             env[0] = "http_proxy=http://"+proxy_url;
    120             env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too
     112           
     113            proxy_url = proxy_url.replaceAll("http://","");
     114           
     115            String [] env = new String[7];
     116           
     117            env[0] = "http_proxy=http://"+proxy_url;
     118            env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too
    121119                           // see also https://wiki.archlinux.org/index.php/proxy_settings
    122             env[2] = "ftp_proxy=ftp://"+proxy_url;
     120            env[2] = "ftp_proxy=ftp://"+proxy_url;
    123121            env[3] = "GSDLHOME=" + Configuration.gsdl_path;
    124122            env[4] = "GSDLOS=" + Gatherer.client_operating_system;
    125123            env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os>
     124            // If PATH is not made available, so that Perl is not on the PATH, then WgetDownload.pm's open3() call
     125            // to run wget fails with cryptic failure message. So make PATH available for open3():
     126            env[6] = "PATH="+System.getenv("PATH");
     127           
    126128            prcs = new SafeProcess(command, env, null);
    127129        }
     
    130132            prcs = new SafeProcess(command);
    131133        }
    132         }
    133134       
    134135        // special processing of Process' stderr stream:
Note: See TracChangeset for help on using the changeset viewer.