Search in sources :

Example 1 with SystemCommandExecutor

use of org.nextprot.api.commons.utils.SystemCommandExecutor in project nextprot-api by calipho-sib.

the class BlastProgram method process.

private O process(List<String> commandLine) throws ExceptionWithReason {
    SystemCommandExecutor commandExecutor = new SystemCommandExecutor(commandLine);
    try {
        commandExecutor.executeCommand();
        String stderr = commandExecutor.getLastExecutionStandardError();
        if (!stderr.isEmpty()) {
            ExceptionWithReason ewr = new ExceptionWithReason();
            ewr.getReason().addCause(name + " exception", stderr.replace("\n", " "));
            ewr.getReason().setMessage("Error while executing " + name);
            throw ewr;
        }
        return buildOutputFromStdout(commandExecutor.getLastExecutionStandardOutput());
    } catch (InterruptedException | IOException e) {
        throw new NextProtException("Internal error: cannot process " + name + " command line " + commandLine, e);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) IOException(java.io.IOException) ExceptionWithReason(org.nextprot.api.commons.utils.ExceptionWithReason) SystemCommandExecutor(org.nextprot.api.commons.utils.SystemCommandExecutor)

Aggregations

IOException (java.io.IOException)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 ExceptionWithReason (org.nextprot.api.commons.utils.ExceptionWithReason)1 SystemCommandExecutor (org.nextprot.api.commons.utils.SystemCommandExecutor)1