feat: ASW-100 env exec playbook 接口开发
This commit is contained in:
@@ -848,4 +848,25 @@ public class AdbUtil {
|
||||
return process;
|
||||
}
|
||||
}
|
||||
|
||||
public CommandResult execPlaybook(String playbookPath) {
|
||||
log.info("[execPlaybook] [begin!]");
|
||||
Process process = CommandExec.execForProcess(new AdbCommandBuilder("airtest")
|
||||
.buildRunPlaybook(playbookPath, this.serial)
|
||||
.build());
|
||||
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<String> future = executor.submit(() -> T.IoUtil.read(process.getInputStream(), T.CharsetUtil.CHARSET_UTF_8));
|
||||
try {
|
||||
int exitCode = process.waitFor();
|
||||
String result = future.get(10, TimeUnit.SECONDS);
|
||||
log.info("[execPlaybook] [result: {}]", result);
|
||||
return new CommandResult(exitCode, result);
|
||||
} catch (Exception e) {
|
||||
process.destroyForcibly();
|
||||
throw new APIException(RCode.ERROR);
|
||||
}finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user