public String characterise(File input) throws PlanningException{
if (FITS_HOME == null) {
throw new PlanningException("FITS is not properly configured (FITS_HOME is not defined).");
}
CommandExecutor cmdExecutor = new CommandExecutor();
cmdExecutor.setWorkingDirectory(FITS_HOME);
String scriptExt;
if ("Linux".equalsIgnoreCase(System.getProperty("os.name"))){
scriptExt = "./fits.sh";
} else {
scriptExt = "cmd /c %FITS_HOME%/fits";
}
File output = new File(OS.getTmpPath() + "fits"+System.nanoTime()+".out");
try {
String commandLine = FITS_COMMAND.replace("%FITS_EXEC%", scriptExt)
.replace("%INPUT%", input.getAbsolutePath())
.replace("%OUTPUT%", output.getAbsolutePath());
try {
int exitcode = cmdExecutor.runCommand(commandLine);
if (exitcode != 0) {
String cmdError = cmdExecutor.getCommandError();
throw new PlanningException("FITS characterisation for file: " + input + " failed: " + cmdError);
}
if (!output.exists()) {
throw new PlanningException("FITS characterisation for file: " + input + " failed: no output was written.");
}