use of com.wuntee.oter.exception.CommandFailedException in project otertool by wuntee.
the class AdbWorkshop method installApk.
public static void installApk(String apk) throws IOException, InterruptedException, CommandFailedException {
TerminatingCommand c = AdbWorkshop.getTerminatingAdbCommand(new String[] { "install", apk });
c.execute();
for (String l : c.getOutput()) {
// Failure [INSTALL_FAILED_ALREADY_EXISTS]
if (l.matches(".*Failure.*")) {
throw new CommandFailedException(c.getCommand(), c.getOutput(), l);
}
}
}
use of com.wuntee.oter.exception.CommandFailedException in project otertool by wuntee.
the class TerminatingCommand method executeNoErrorMonitor.
public int executeNoErrorMonitor() throws CommandFailedException, InterruptedException, IOException {
this.child = Runtime.getRuntime().exec(this.command);
BufferedReader b = new BufferedReader(new InputStreamReader(this.child.getInputStream()));
String l;
while ((l = b.readLine()) != null) {
logger.debug("STDOUT: " + l);
;
output.add(l);
}
this.returnCode = this.child.waitFor();
logger.debug("Return code: " + this.returnCode);
if (this.returnCode != 0) {
List<String> ex = new LinkedList<String>();
ex.addAll(output);
ex.addAll(error);
throw new CommandFailedException(this.command, ex, this.returnCode);
}
return (this.returnCode);
}
use of com.wuntee.oter.exception.CommandFailedException in project otertool by wuntee.
the class TerminatingCommand method execute.
public int execute() throws IOException, InterruptedException, CommandFailedException {
if (workingDirectory != null) {
String cmd = "";
for (String c : this.command) {
cmd = cmd + c + " ";
}
logger.debug("Executing command: " + cmd + " in working directory:" + workingDirectory);
this.child = Runtime.getRuntime().exec(this.command, new String[] {}, workingDirectory);
} else {
this.child = Runtime.getRuntime().exec(this.command);
}
BufferedReader b = new BufferedReader(new InputStreamReader(this.child.getErrorStream()));
String l;
while ((l = b.readLine()) != null) {
logger.debug("STDERR: " + l);
error.add(l);
}
b = new BufferedReader(new InputStreamReader(this.child.getInputStream()));
while ((l = b.readLine()) != null) {
logger.debug("STDOUT: " + l);
;
output.add(l);
}
this.returnCode = this.child.waitFor();
logger.debug("Return code: " + this.returnCode);
if (this.returnCode != 0) {
List<String> ex = new LinkedList<String>();
ex.addAll(output);
ex.addAll(error);
throw new CommandFailedException(this.command, ex, this.returnCode);
}
return (this.returnCode);
}
Aggregations