feat: ASW-100 env exec playbook 接口开发

This commit is contained in:
zhangshuai
2024-10-17 17:10:45 +08:00
parent 28e34185c5
commit 05bacb1bf3
4 changed files with 171 additions and 1 deletions

View File

@@ -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();
}
}
}