- Timestamp:
- 2017-04-21T21:09:08+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r31583 r31636 60 60 import org.greenstone.gatherer.util.GS3ServerThread; 61 61 import org.greenstone.gatherer.util.JarTools; 62 import org.greenstone.gatherer.util.SafeProcess; 62 63 import org.greenstone.gatherer.util.StaticStrings; 63 64 import org.greenstone.gatherer.util.Utility; … … 1433 1434 1434 1435 1435 /** This private class contains an instance of an external application running within a JVM shell. It is important that this process sits in its own thread, but its more important that when we exit the Gatherer we don't actually System.exit(0) the Gatherer object until the user has volunt eerily ended all of these child processes. Otherwise when we quit the Gatherer any changes the users may have made in external programs will be lost and the child processes are automatically deallocated. */1436 /** This private class contains an instance of an external application running within a JVM shell. It is important that this process sits in its own thread, but its more important that when we exit the Gatherer we don't actually System.exit(0) the Gatherer object until the user has voluntarily ended all of these child processes. Otherwise when we quit the Gatherer any changes the users may have made in external programs will be lost and the child processes are automatically deallocated. */ 1436 1437 static private class ExternalApplication 1437 1438 extends Thread { … … 1629 1630 boolean found = false; 1630 1631 1631 try {1632 1632 1633 // run the command `/path/to/perl -S gs-magick.pl identify -version` 1633 1634 ArrayList cmd_list = new ArrayList(); … … 1656 1657 } 1657 1658 DebugStream.println("***** Running ImageMagickTest command: " + cmd_str); 1658 1659 Process image_magick_process = Runtime.getRuntime().exec(command_parts); 1660 image_magick_process.waitFor(); 1661 1662 //new way of detection of ImageMagick 1663 InputStreamReader isr = new InputStreamReader(image_magick_process.getInputStream()); 1664 1665 BufferedReader br = new BufferedReader(isr); 1666 // Capture the standard output stream and seach for two particular occurrences: Version and ImageMagick. 1667 1668 String line = br.readLine(); 1669 if (line != null) { 1670 String lc_line = line.toLowerCase(); 1671 if (lc_line.indexOf("version") != -1 || lc_line.indexOf("imagemagick") != -1) { 1672 //System.err.println("*** ImageMagickTest Line: " + line); 1673 found = true; 1674 } // else found var remains false 1675 } 1676 1677 // Maybe put the close in a finally (but note that it can throw and IOex too)? See 1678 // http://download.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html 1679 br.close(); 1680 return found; 1681 //return (image_magick_process.exitValue() == 0); 1682 } 1683 catch (Exception exception) { 1684 exception.printStackTrace(); 1659 System.err.println("***** Running ImageMagickTest command: " + cmd_str); 1660 1661 SafeProcess image_magick_process = new SafeProcess(command_parts); 1662 int exitValue = image_magick_process.runProcess(); // default process iostream handling 1663 //new way of detection of ImageMagick 1664 // Inspect the standard output of the process and seach for two particular occurrences: Version and ImageMagick. 1665 String output = image_magick_process.getStdOutput().toLowerCase(); 1666 if (output.indexOf("version") != -1 || output.indexOf("imagemagick") != -1) { 1667 System.err.println("*** ImageMagickTest output: " + output); 1668 found = true; 1669 } // else found var remains false 1670 1685 1671 return found; 1686 } 1672 //return (image_magick_process.exitValue() == 0); 1673 1687 1674 } 1688 1675 } … … 1702 1689 { 1703 1690 try { 1704 Process perl_process = Runtime.getRuntime().exec(command);1705 perl_process.waitFor();1706 return (perl_process.exitValue()== 0);1691 SafeProcess perl_process = new SafeProcess(command); 1692 int exitValue = perl_process.runBasicProcess(); 1693 return (exitValue == 0); 1707 1694 } 1708 1695 catch (Exception exception) {
Note:
See TracChangeset
for help on using the changeset viewer.