MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / GnuplotInstaller

Class GnuplotInstaller

src/tools/GnuplotInstaller.java:29–108  ·  view source on GitHub ↗

Title: GnuplotInstaller Description: Installs the gnuplot invocation shell file

Source from the content-addressed store, hash-verified

27 */
28
29public class GnuplotInstaller {
30 private static final boolean IS_WINDOWS =
31 System.getProperty("os.name", "").contains("Windows");
32
33 /** Static class logger */
34 private static final Logger LOG = LoggerFactory.getLogger(GnuplotInstaller.class);
35
36 /** The name of the shell file */
37 public static final String GP_BATCH_FILE_NAME = IS_WINDOWS ? "mygnuplot.bat" : "mygnuplot.sh";
38 /** The name of the gnuplot executable */
39 public static final String GP_NAME = IS_WINDOWS ? "gnuplot.exe" : "gnuplot";
40
41 /** The directory where shell file will be installed */
42 public static final String GP_DIR = System.getProperty("java.io.tmpdir") + File.separator + ".tsdb" + File.separator + "tsdb-gnuplot";
43 /** The java/io file representing the gnuplot shell file */
44 public static final File GP_FILE = new File(GP_DIR, GP_BATCH_FILE_NAME);
45 /** Indicates if gnuplot was found on the path */
46 public static final boolean FOUND_GP;
47
48 static {
49 boolean found = false;
50 final String PATH = System.getenv("PATH");
51 if(PATH!=null) {
52 final String[] paths = PATH.split(File.pathSeparator);
53 for(String path: paths) {
54 LOG.debug("Inspecting PATH for Gnuplot Exe: [{}]", path);
55 File dir = new File(path.trim());
56 if(dir.exists() && dir.isDirectory()) {
57 File gp = new File(dir, GP_NAME);
58 if(gp.exists()) {
59 found = true;
60 LOG.info("Found gnuplot at [{}]", gp.getAbsolutePath());
61 break;
62 }
63
64 }
65 }
66 }
67 FOUND_GP = found;
68 if(!found) LOG.warn("Failed to locate Gnuplot executable");
69 }
70
71 private GnuplotInstaller() {
72
73 }
74
75 /**
76 * Installs the mygnuplot shell file
77 */
78 public static void installMyGnuPlot() {
79 if(!FOUND_GP) {
80 LOG.warn("Skipping Gnuplot Shell Script Install since Gnuplot executable was not found");
81 return;
82 }
83 if(!GP_FILE.exists()) {
84 if(!GP_FILE.getParentFile().exists()) {
85 GP_FILE.getParentFile().mkdirs();
86 }

Callers

nothing calls this directly

Calls 2

containsMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…