Ignore:
Timestamp:
2017-04-06T15:24:43+12:00 (7 years ago)
Author:
ak19
Message:

Removed debugging and other minor cosmetic changes after successful Windows testing of the new SafeProcess class used by the modified GS2PerlConstructor.runPerlCommand() method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java

    r31574 r31578  
    9797//***************** Copied from gli's gui/FormatConversionDialog.java *************//
    9898    public void runProcess() {
     99
    99100    Process prcs = null;
    100101    SafeProcess.OutputStreamGobbler inputGobbler = null;
     
    103104
    104105    try {       
    105        
    106106        Runtime rt = Runtime.getRuntime();     
    107107       
    108        
    109108        // http://stackoverflow.com/questions/5283444/convert-array-of-strings-into-a-string-in-java
    110         logger.info("Running process: " + Arrays.toString(command_args));
     109        //logger.info("Running process: " + Arrays.toString(command_args));
    111110
    112111        if(this.envp == null) {
     
    115114
    116115        if(this.dir == null) {
    117             logger.info("\twith: " + Arrays.toString(this.envp));
     116            //logger.info("\twith: " + Arrays.toString(this.envp));
    118117            prcs = rt.exec(this.command_args, this.envp);
    119118        } else {
    120             logger.info("\tfrom directory: " + this.dir);
    121             logger.info("\twith: " + Arrays.toString(this.envp));
     119            //logger.info("\tfrom directory: " + this.dir);
     120            //logger.info("\twith: " + Arrays.toString(this.envp));
    122121            prcs = rt.exec(this.command_args, this.envp, this.dir);
    123122        }
    124123        }
    125124
    126         logger.info("### Before creating ProcessInGobbler");
    127 
    128        
    129125        // send inputStr to process. The following constructor can handle inputStr being null
    130126        inputGobbler = // WriterToProcessInputStream
    131127        new SafeProcess.OutputStreamGobbler(prcs.getOutputStream(), this.inputStr);
    132128       
    133         logger.info("### Before creating ProcessErrGobbler");
    134        
    135129        // monitor for any error messages
    136130            errorGobbler // ReaderFromProcessOutputStream
    137131        = new SafeProcess.InputStreamGobbler(prcs.getErrorStream(), splitStdOutputNewLines);
    138132
    139         logger.info("### Before creating ProcessOutGobbler");
    140 
    141133            // monitor for the expected std output line(s)
    142134            outputGobbler
    143135        = new SafeProcess.InputStreamGobbler(prcs.getInputStream(), splitStdErrorNewLines);
    144 
    145         logger.info("### Before setting handlers on ProcessGobblers");
    146136                   
    147137        // register line by line handlers, if any were set, for the process stderr and stdout streams
     
    156146        }       
    157147
    158         logger.info("### Before streamgobblers.start()");
    159 
    160148            // kick off the stream gobblers
    161149            inputGobbler.start();
    162150            errorGobbler.start();
    163151            outputGobbler.start();
    164 
    165         logger.info("### After streamgobblers.start() - before waitFor");
    166152                                   
    167153            // any error???
    168154            this.exitValue = prcs.waitFor(); // can throw an InterruptedException if process did not terminate             
    169             logger.info("ExitValue: " + exitValue);
    170 
    171         logger.info("### Before streamgobblers.join()");
    172 
    173155        // From the comments of
    174156        // http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html?page=2
     
    180162        inputGobbler.join();
    181163       
    182         logger.info("### After streamgobblers.join()");
    183 
    184164        // set the variables the code that created a SafeProcess object may want to inspect
    185165        this.outputStr = outputGobbler.getOutput();
    186166        this.errorStr = errorGobbler.getOutput();
    187167
    188         // the calling code should handle errorStr, not us, so can leave out the following code
    189         /*
    190           if(!this.errorStr.equals("")) {
    191           logger.info("*** Process errorstream: \n" + this.errorStr + "\n****");
    192           //System.err.println("*** Process errorstream: \n" + this.errorStr + "\n****");
    193           }
    194         */
    195        
    196168        // Since we didn't have an exception, process should have terminated now (waitFor blocks until then)
    197169        // Set process to null so we don't forcibly terminate it below with process.destroy()
Note: See TracChangeset for help on using the changeset viewer.