Changeset 31877 for main/trunk/gli/src


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.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

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

    r31865 r31877  
    619619
    620620        String [] env = null;
    621          
    622         if (Utility.isWindows()) {
    623                 prcs = new SafeProcess(cmd);
    624         }
    625         else {
     621
    626622        if (proxy_url != null && !proxy_url.equals("")) {           
    627623            // Specify proxies as environment variables
    628624            // Need to manually specify GSDLHOME and GSDLOS also
    629             env = new String[6];
    630                     proxy_url = proxy_url.replaceAll("http://","");
    631             env[0] = "http_proxy=http://"+proxy_url;
    632             env[1] = "https_proxy=http://"+proxy_url; // HTTP protocol for https:// too
    633                         // see also https://wiki.archlinux.org/index.php/proxy_settings
    634             env[2] = "ftp_proxy=ftp://"+proxy_url;
     625           
     626            proxy_url = proxy_url.replaceAll("http://","");
     627                   
     628            env = new String[7];
     629           
     630            env[0] = "http_proxy=http://"+proxy_url;
     631            env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too
     632                           // see also https://wiki.archlinux.org/index.php/proxy_settings
     633            env[2] = "ftp_proxy=ftp://"+proxy_url;
    635634            env[3] = "GSDLHOME=" + Configuration.gsdl_path;
    636635            env[4] = "GSDLOS=" + Gatherer.client_operating_system;
    637636            env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os>
     637            // If PATH is not made available, so that Perl is not on the PATH, then WgetDownload.pm's open3() call
     638            // to run wget fails with cryptic failure message. So make PATH available for open3():
     639            env[6] = "PATH="+System.getenv("PATH");     
     640           
    638641            prcs = new SafeProcess(cmd, env, null);
    639642        }
    640         else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled) {
     643        else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) {
    641644            // Not Windows, but running client with download panel
    642645            // Need to manually specify GSDLHOME and GSDLOS
     
    651654            prcs = new SafeProcess(cmd);
    652655        }
    653         }
     656
    654657        //System.out.println(newcmd);
    655658        prcs.setMainHandler(this); // attach handler to clean up before and after process.destroy()
  • 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:
  • main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java

    r31864 r31877  
    780780       
    781781        // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the following can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this
    782         if (Utility.isWindows()) {
     782        /*if (Utility.isWindows()) {
    783783       
    784784           arg = current_download.getArgument("user_name");
     
    790790           arg.setAssigned(true);
    791791          }
    792            else{
     792         
     793           else{*/
    793794            String user_name = user_pass.substring(0, user_pass.indexOf("@"));
    794795            String user_pwd = user_pass.substring(user_pass.indexOf("@") + 1);
    795796            proxy_url = user_name+":"+user_pwd+"@"+proxy_host+":"+proxy_port+"/";
    796797           
    797            }
     798           /*}*/
    798799       
    799800           return true;
Note: See TracChangeset for help on using the changeset viewer.