Iterate through the class path and look for the Gnuplot helper script. @return The path to the wrapper script.
()
| 1013 | * @return The path to the wrapper script. |
| 1014 | */ |
| 1015 | private static String findGnuplotHelperScript() { |
| 1016 | if(!GnuplotInstaller.FOUND_GP) { |
| 1017 | LOG.warn("Skipping Gnuplot Shell Script Install since Gnuplot executable was not found"); |
| 1018 | return null; |
| 1019 | } |
| 1020 | if(!GnuplotInstaller.GP_FILE.exists()) { |
| 1021 | GnuplotInstaller.installMyGnuPlot(); |
| 1022 | } |
| 1023 | if(GnuplotInstaller.GP_FILE.exists() && GnuplotInstaller.GP_FILE.canExecute()) { |
| 1024 | LOG.info("Auto Installed Gnuplot Invoker at [{}]", GnuplotInstaller.GP_FILE.getAbsolutePath()); |
| 1025 | return GnuplotInstaller.GP_FILE.getAbsolutePath(); |
| 1026 | } |
| 1027 | |
| 1028 | final URL url = GraphHandler.class.getClassLoader().getResource(WRAPPER); |
| 1029 | if (url == null) { |
| 1030 | throw new RuntimeException("Couldn't find " + WRAPPER + " on the" |
| 1031 | + " CLASSPATH: " + System.getProperty("java.class.path")); |
| 1032 | } |
| 1033 | final String path = url.getFile(); |
| 1034 | LOG.debug("Using Gnuplot wrapper at {}", path); |
| 1035 | final File file = new File(path); |
| 1036 | final String error; |
| 1037 | if (!file.exists()) { |
| 1038 | error = "non-existent"; |
| 1039 | } else if (!file.canExecute()) { |
| 1040 | error = "non-executable"; |
| 1041 | } else if (!file.canRead()) { |
| 1042 | error = "unreadable"; |
| 1043 | } else { |
| 1044 | return path; |
| 1045 | } |
| 1046 | throw new RuntimeException("The " + WRAPPER + " found on the" |
| 1047 | + " CLASSPATH (" + path + ") is a " + error + " file... WTF?" |
| 1048 | + " CLASSPATH=" + System.getProperty("java.class.path")); |
| 1049 | } |
| 1050 | |
| 1051 | |
| 1052 | // ---------------- // |
no test coverage detected