Package eu.planets_project.pp.plato.util

Examples of eu.planets_project.pp.plato.util.CommandExecutor


    public RunInfo run()  {
        RunInfo r = new RunInfo();
   
        log.debug("running tool: "+command);
        CommandExecutor cmdExecutor = new CommandExecutor();    
        if (workingDir != null) {
            cmdExecutor.setWorkingDirectory(workingDir);
        }
        long startTime = System.nanoTime();
        try {
            int exitStatus = cmdExecutor.runCommand(command);
            r.setSuccess(exitStatus == 0);
            r.setReport(cmdExecutor.getCommandError());
           
            if (r.isSuccess() && "".equals(r.getReport())) {
                String report = cmdExecutor.getCommandOutput();
                if ("".equals(report)) {
                    r.setReport("Successfully executed command.");
                } else {
                    r.setReport(report);
                }
View Full Code Here


        return tempDir+"xcl"+time+"/";
    }
   
    private String extract(String file) {
        String outXCDL = file+".xcdl";
        CommandExecutor cmdExecutor = new CommandExecutor();    
        try {
            cmdExecutor.setWorkingDirectory(getConfigParam());
            /* now we have to expand the command with the working directory! */
            String cmd = getConfigParam() + extractorCommand.replace("%FILE%", file)
                                         .replace("%XCDL%", outXCDL);
           
            int exitStatus = cmdExecutor.runCommand(cmd);
            if (exitStatus == 0) {
               // WHAT IS THE OUTPUT FILE??
            } else {
                log.error("Problem calling Extractor on file "+file+" : "+cmdExecutor.getCommandError());
                outXCDL = null;
            }
        } catch (Exception e) {
          log.error("Problem calling Extractor on file "+file,e);
          outXCDL = null;
View Full Code Here

        return outXCDL;
    }
   
   
    private String compare(String in, String out, String pcr, String workingDir) {
        CommandExecutor cmdExecutor = new CommandExecutor();    
        try {
            cmdExecutor.setWorkingDirectory(getConfigParam());
            /* now we have to expand the command with the working directory! */
            String cmd = getConfigParam() + comparatorCommand.replace("%XCDL1%", in)
                                          .replace("%XCDL2%", out)
                                          .replace("%PCR%", pcr)
                                          .replace("%OUTDIR%", workingDir);
           
            int exitStatus = cmdExecutor.runCommand(cmd);
            if (exitStatus != 0) {
                log.error("Problem calling Comparator on files "+in+", "+out+", "+pcr+" : "+cmdExecutor.getCommandError());
                return "";
            }
        } catch (Exception e) {
          log.error("Problem calling Comparator on files "+in+", "+out+", "+pcr,e);
          return "";
View Full Code Here

   
    public Double evaluate(String tempDir, String file1,String file2, String metric) {
        String commandTemplate = compareCommand.replace("%FILE1%", file1)
                                               .replace("%FILE2%", file2);
       
        CommandExecutor cmdEx = new CommandExecutor();
        cmdEx.setWorkingDirectory(OS.getTmpPath());
        String command = commandTemplate.replace("%METRIC%", metric);
        try {
            cmdEx.runCommand(command);
            String out = cmdEx.getCommandError();
            log.debug(command+ " == "+out);
            Double value = Scale.MAX_VALUE;

            try {
                if (out.contains(" ")) {
                    out = out.substring(0,out.indexOf(" "));
                }
                value = Double.valueOf(out.trim());
            } catch (NumberFormatException e) {
                log.error("unknown numberformat: "+out+" "+e.getMessage());
            }
            return value;
        } catch (Exception e) {
            log.error("error during image comparison "+command+" : "+cmdEx.getCommandError(),e);
            return null;
        }
    }
View Full Code Here

            throw new PlatoServiceException("FITS is not propertly configured - FITS_HOME is not defined.");
        }
    }
   
    public String characterise(File input) throws PlatoServiceException{
        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 PlatoServiceException("FITS characterisation for file: " + input + " failed: " + cmdError);
                }
                if (!output.exists()) {
                    throw new PlatoServiceException("FITS characterisation for file: " + input + " failed: no output was written.");
                }
View Full Code Here

     * @param filename
     * @return filename of XCDL description: <param>filename</param> + .xcdl
     */
    public String extractXCDL(String filename) {
        String outXCDL = filename+".xcdl";
        CommandExecutor cmdExecutor = new CommandExecutor();    
        try {
            cmdExecutor.setWorkingDirectory(extractorHome);
            /* now we have to expand the command with the working directory! */
            String cmd = extractorHome + extractorCommand.replace("%FILE%", filename)
                                         .replace("%XCDL%", outXCDL);
           
            int exitStatus = cmdExecutor.runCommand(cmd);
            if (exitStatus == 0) {
               // WHAT IS THE OUTPUT FILE??
            } else {
                log.error("Problem calling Extractor on file "+filename+" : "+cmdExecutor.getCommandError());
                outXCDL = null;
            }
        } catch (Exception e) {
          log.error("Problem calling Extractor on file "+filename,e);
          outXCDL = null;
View Full Code Here

     * @param pcr
     * @param workingDir
     * @return filename of the comparator result (including the path), or an empty string if the call failed
     */
    private String callComparator(String in, String out, String pcr, String workingDir) {
        CommandExecutor cmdExecutor = new CommandExecutor();    
        try {
            cmdExecutor.setWorkingDirectory(comparatorHome);
            /* now we have to expand the command with the working directory! */
            String cmd = comparatorHome + comparatorCommand.replace("%XCDL1%", in)
                                          .replace("%XCDL2%", out)
                                          .replace("%PCR%", pcr)
                                          .replace("%OUTDIR%", workingDir);
           
            int exitStatus = cmdExecutor.runCommand(cmd);
            if (exitStatus != 0) {
                log.error("Problem calling Comparator on files "+in+", "+out+", "+pcr+" : "+cmdExecutor.getCommandError());
                return "";
            }
        } catch (Exception e) {
          log.error("Problem calling Comparator on files "+in+", "+out+", "+pcr,e);
          return "";
View Full Code Here

        String xcelString;
        String tempDir = makeTempDir();
        String command = xclExplorerPath+"XCLExplorer "+PUIDs+ " -o "+tempDir;
       
        try {
            CommandExecutor cmdExecutor = new CommandExecutor();
            cmdExecutor.setWorkingDirectory(xclExplorerPath);
            try {
                int exitStatus = cmdExecutor.runCommand(command);
                // r.setSuccess(exitStatus == 0);
                //r.setReport(cmdExecutor.getCommandError());
            } catch (Exception e) {
              log.error(e.getMessage(),e);
            }
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.util.CommandExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.