Changeset 31585

Show
Ignore:
Timestamp:
06.04.2017 21:03:08 (2 years ago)
Author:
ak19
Message:

GLI's DownloadPane?.java now also uses SafeProcess?.java when running a perl process from Java.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java

    r31582 r31585  
    240240    private ArrayList<String> loadDownloadersInfo(String lang) { 
    241241    Document document = null; 
    242     Process process = null; 
    243242     
    244243    try { 
     
    267266        // Create the process. 
    268267        args = (String []) args_list.toArray(new String[0]); 
    269         Runtime runtime = Runtime.getRuntime(); 
     268 
     269        SafeProcess process = new SafeProcess(args); 
    270270        DebugStream.println("Getting Download Info: "+args_list); 
    271         process = runtime.exec(args); 
    272          
    273         InputStream input_stream = process.getErrorStream(); 
    274         document = XMLTools.parseXML(input_stream); 
     271 
     272        // run the SafeProcess 
     273        int exitVal = process.runProcess(); 
     274        if(exitVal != 0) { 
     275            throw new Exception("*** Error running Download Info process, process exited with: " 
     276                    + exitVal); 
     277        }        
     278         
     279        // get the result and process it. 
     280        // This time we expect XML to have come out of the process std error stream. 
     281        String errStreamOutput = process.getStdError(); 
     282        StringReader xmlStrReader = new StringReader(errStreamOutput); 
     283        document = XMLTools.parseXML(xmlStrReader); 
     284        xmlStrReader.close(); 
     285         
    275286        } 
    276287 
     
    280291        System.err.println("Failed when trying to parse downloadinfo.pl -describeall"); 
    281292        error.printStackTrace(); 
    282     }  
    283     finally { 
    284         SafeProcess.closeProcess(process); 
    285293    } 
    286294 
  • main/trunk/gli/src/org/greenstone/gatherer/util/SafeProcess.java

    r31583 r31585  
    2323    //static Logger logger = Logger.getLogger(org.greenstone.util.SafeProcess.class.getName()); 
    2424 
     25    // input to SafeProcess and initialising it 
    2526    private String command = null; 
    2627    private String[] command_args = null; 
     
    2930    private String inputStr = null; 
    3031 
     32    // output from running SafeProcess.runProcess() 
    3133    private String outputStr = "";  
    3234    private String errorStr = ""; 
    33  
    3435    private int exitValue = -1; 
    3536 
     
    5253    } 
    5354 
     55    // cmd string version 
    5456    public SafeProcess(String cmdStr) 
    5557    {