Changeset 31878 for main

Show
Ignore:
Timestamp:
11.08.2017 18:22:36 (2 years ago)
Author:
ak19
Message:

1. Previous commit message was incorrect: it wasn't that perl wasn't found that resulted in the open3() failure error message, but that something on the PATH wasn't available to it, possible wget itself. 2. Updating unused DownloadJob?.old_callDownload() to have the recently committed changes in callDownload(). 3. Emacs tabbing for recently committed files.

Location:
main/trunk
Files:
4 modified

Legend:

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

    r31877 r31878  
    310310        Process prcs = null;  
    311311 
    312           
    313         if (Utility.isWindows()) { 
    314                 prcs = rt.exec(cmd);    
     312        if (proxy_url != null && !proxy_url.equals("")) {            
     313        // Specify proxies as environment variables 
     314        // Need to manually specify GSDLHOME and GSDLOS also 
     315         
     316        proxy_url = proxy_url.replaceAll("http://",""); 
     317         
     318        env = new String[7]; 
     319         
     320        env[0] = "http_proxy=http://"+proxy_url; 
     321        env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 
     322        // see also https://wiki.archlinux.org/index.php/proxy_settings 
     323        env[2] = "ftp_proxy=ftp://"+proxy_url; 
     324        env[3] = "GSDLHOME=" + Configuration.gsdl_path; 
     325        env[4] = "GSDLOS=" + Gatherer.client_operating_system; 
     326        // teach it where the wgetrc file lives, in gs2build/bin/<os>: 
     327        env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 
     328        // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 
     329        // WgetDownload.pm's open3()  call is not on the PATH, then the perl open() call to run wget fails. 
     330        // So make PATH available to get open3() working: 
     331        env[6] = "PATH="+System.getenv("PATH");      
     332         
     333        prcs = rt.exec(cmd, env); 
     334        }  
     335        else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) { 
     336        // Not Windows, but running client with download panel 
     337        // Need to manually specify GSDLHOME and GSDLOS 
     338        env = new String[3]; 
     339        env[0] = "GSDLHOME=" + Configuration.gsdl_path; 
     340        env[1] = "GSDLOS=" + Gatherer.client_operating_system; 
     341        env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 
     342        prcs = rt.exec(cmd, env); 
    315343        } 
    316344        else { 
    317         if (proxy_url != null && !proxy_url.equals("")) {            
    318             // Specify proxies as environment variables 
    319             // Need to manually specify GSDLHOME and GSDLOS also 
    320             env = new String[6]; 
    321                     proxy_url = proxy_url.replaceAll("http://",""); 
    322             env[0] = "http_proxy=http://"+proxy_url; 
    323             env[1] = "https_proxy=http://"+proxy_url; // HTTP protocol for https:// too 
    324                         // see also https://wiki.archlinux.org/index.php/proxy_settings 
    325             env[2] = "ftp_proxy=ftp://"+proxy_url; 
    326             env[3] = "GSDLHOME=" + Configuration.gsdl_path; 
    327             env[4] = "GSDLOS=" + Gatherer.client_operating_system; 
    328             env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 
    329             prcs = rt.exec(cmd, env);  
    330         }  
    331         else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled) { 
    332             // Not Windows, but running client with download panel 
    333             // Need to manually specify GSDLHOME and GSDLOS 
    334             env = new String[3]; 
    335             env[0] = "GSDLHOME=" + Configuration.gsdl_path; 
    336             env[1] = "GSDLOS=" + Gatherer.client_operating_system; 
    337             env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 
    338             prcs = rt.exec(cmd, env);  
    339         } 
    340         else { 
    341             // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 
    342             prcs = rt.exec(cmd); 
    343         } 
     345        // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 
     346        prcs = rt.exec(cmd); 
    344347        } 
    345348        //System.out.println(newcmd);        
     
    620623        String [] env = null; 
    621624 
    622         if (proxy_url != null && !proxy_url.equals("")) {            
    623             // Specify proxies as environment variables 
    624             // Need to manually specify GSDLHOME and GSDLOS also 
    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; 
    634             env[3] = "GSDLHOME=" + Configuration.gsdl_path; 
    635             env[4] = "GSDLOS=" + Gatherer.client_operating_system; 
    636             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              
    641             prcs = new SafeProcess(cmd, env, null); 
    642         }  
    643         else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) { 
    644             // Not Windows, but running client with download panel 
    645             // Need to manually specify GSDLHOME and GSDLOS 
    646             env = new String[3]; 
    647             env[0] = "GSDLHOME=" + Configuration.gsdl_path; 
    648             env[1] = "GSDLOS=" + Gatherer.client_operating_system; 
    649             env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 
    650             prcs = new SafeProcess(cmd, env, null); 
    651         } 
    652         else { 
    653             // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 
    654             prcs = new SafeProcess(cmd); 
    655         } 
    656  
     625        if (proxy_url != null && !proxy_url.equals("")) {            
     626        // Specify proxies as environment variables 
     627        // Need to manually specify GSDLHOME and GSDLOS also 
     628         
     629        proxy_url = proxy_url.replaceAll("http://",""); 
     630         
     631        env = new String[7]; 
     632         
     633        env[0] = "http_proxy=http://"+proxy_url; 
     634        env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 
     635        // see also https://wiki.archlinux.org/index.php/proxy_settings 
     636        env[2] = "ftp_proxy=ftp://"+proxy_url; 
     637        env[3] = "GSDLHOME=" + Configuration.gsdl_path; 
     638        env[4] = "GSDLOS=" + Gatherer.client_operating_system; 
     639        // teach it where the wgetrc file lives, in gs2build/bin/<os>: 
     640        env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 
     641        // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 
     642        // WgetDownload.pm's open3()  call is not on the PATH, then the perl open() call to run wget fails. 
     643        // So make PATH available to get open3() working: 
     644        env[6] = "PATH="+System.getenv("PATH");      
     645         
     646        prcs = new SafeProcess(cmd, env, null); 
     647        }  
     648        else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) { 
     649        // Not Windows, but running client with download panel 
     650        // Need to manually specify GSDLHOME and GSDLOS 
     651        env = new String[3]; 
     652        env[0] = "GSDLHOME=" + Configuration.gsdl_path; 
     653        env[1] = "GSDLOS=" + Gatherer.client_operating_system; 
     654        env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; // teach it where the wgetrc file lives, in gs2build/bin/<os> 
     655        prcs = new SafeProcess(cmd, env, null); 
     656        } 
     657        else { 
     658        // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 
     659        prcs = new SafeProcess(cmd); 
     660        } 
     661         
    657662        //System.out.println(newcmd); 
    658663        prcs.setMainHandler(this); // attach handler to clean up before and after process.destroy() 
  • main/trunk/gli/src/org/greenstone/gatherer/download/ServerInfoDialog.java

    r31877 r31878  
    111111            // Need to manually specify GSDLHOME and GSDLOS also 
    112112             
    113             proxy_url = proxy_url.replaceAll("http://",""); 
    114              
    115             String [] env = new String[7]; 
     113            proxy_url = proxy_url.replaceAll("http://",""); 
    116114             
    117             env[0] = "http_proxy=http://"+proxy_url; 
    118             env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 
    119                            // see also https://wiki.archlinux.org/index.php/proxy_settings 
    120             env[2] = "ftp_proxy=ftp://"+proxy_url; 
     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 
     119            // see also https://wiki.archlinux.org/index.php/proxy_settings 
     120            env[2] = "ftp_proxy=ftp://"+proxy_url; 
    121121            env[3] = "GSDLHOME=" + Configuration.gsdl_path; 
    122122            env[4] = "GSDLOS=" + Gatherer.client_operating_system; 
    123             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              
     123            // teach it where the wgetrc file lives, in gs2build/bin/<os>: 
     124            env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 
     125            // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 
     126            // WgetDownload.pm's open3()  call is not on the PATH, then the perl open() call to run wget fails. 
     127            // So make PATH available to get open3() working: 
     128            env[6] = "PATH="+System.getenv("PATH"); 
     129             
    128130            prcs = new SafeProcess(command, env, null); 
    129131        }  
  • main/trunk/greenstone2/perllib/downloaders/WebDownload.pm

    r31877 r31878  
    193193    my $strBaseCMD = $strOptions." --tries=2 -q -O - \"$self->{'url'}\""; 
    194194 
    195     #&util::print_env(STDERR, "https_proxy", "http_proxy", "HTTPS_PROXY", "HTTP_PROXY", "ftp_proxy", "FTP_PROXY"); 
    196     #&util::print_env(STDERR);   
    197      
     195    #&util::print_env(STDERR, "https_proxy", "http_proxy", "HTTPS_PROXY", "HTTP_PROXY", "ftp_proxy", "FTP_PROXY"); 
     196    #&util::print_env(STDERR);   
     197     
    198198    my $strIdentifyText = $self->useWget($strBaseCMD); 
    199199     
  • main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm

    r31877 r31878  
    169169sub addProxySettingsAsWgetFlags 
    170170{ 
    171     my ($self) = @_; 
    172     my $strOptions = ""; 
    173      
    174     if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 
    175     { 
    176         $strOptions .= " -e https_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";   
    177         $strOptions .= " -e http_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";        
    178          
    179         if ($self->{'user_name'} && $self->{'user_password'}) 
    180         { 
    181         $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 
    182         } 
    183     } 
    184  
    185     if ($self->{'proxy_on'}) { 
    186         $strOptions .= " --proxy "; 
    187     } 
    188      
    189     return $strOptions; 
    190 } 
    191  
    192 sub getWgetOptions 
    193 { 
    194171    my ($self) = @_; 
    195172    my $strOptions = ""; 
    196173     
    197     # If proxy settings are set up in the environment, wget is ready to use them. More secure. 
    198     # But if proxy settings are not set up in the environment, pass them as flags to wget 
    199     # This is less secure, as pwd etc visible in task manager, but it was the original way in 
    200     # which wget was run on windows. 
    201     # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 
     174    if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 
     175    { 
     176    $strOptions .= " -e https_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";   
     177    $strOptions .= " -e http_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";        
     178     
     179    if ($self->{'user_name'} && $self->{'user_password'}) 
     180    { 
     181        $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 
     182    } 
     183    } 
     184     
     185    if ($self->{'proxy_on'}) { 
     186    $strOptions .= " --proxy "; 
     187    } 
     188     
     189    return $strOptions; 
     190} 
     191 
     192sub getWgetOptions 
     193{ 
     194    my ($self) = @_; 
     195    my $strOptions = ""; 
     196     
     197    # If proxy settings are set up in the environment, wget is ready to use them. More secure. 
     198    # But if proxy settings are not set up in the environment, pass them as flags to wget 
     199    # This is less secure, as pwd etc visible in task manager, but it was the original way in 
     200    # which wget was run on windows. 
     201    # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 
    202202    # http://www.perlmonks.org/?node=what%20is%20true%20and%20false%20in%20Perl%3F 
    203  
     203     
    204204    if (!$ENV{'http_proxy'} && !$ENV{'https_proxy'}) { 
    205         $strOptions .= $self->addProxySettingsAsWgetFlags(); 
     205    $strOptions .= $self->addProxySettingsAsWgetFlags(); 
    206206    } # else wget will use proxy settings in environment, assume enough settings have been provided 
     207     
     208    if($self->{'no_check_certificate'}) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http 
    207209     
    208     if($self->{'no_check_certificate'}) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http 
    209  
    210210    $strOptions .= " --no-check-certificate "; 
    211211    } 
    212      
     212     
    213213    return $strOptions; 
    214214} 
     
    288288    # closing an extra unused handle, a single handle is used instead for both the child's 
    289289    # stderr and stdout. 
    290     # See http://blog.0x1fff.com/2009/09/howto-execute-system-commands-in-perl.html 
    291     # for why this is the right thing to do. 
     290    # See http://blog.0x1fff.com/2009/09/howto-execute-system-commands-in-perl.html 
     291    # for why this is the right thing to do. 
    292292 
    293293    # Both open2 and open3 don't return on failure, but raise an exception. The handling