mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(LocalRunnerClient): co-locate system execution result
This commit is contained in:
@@ -126,7 +126,7 @@ public class LocalRunnerClient extends RunnerClient {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
String[] commands = SystemExecHelper.buildCommands(ext, metaAction.getParams(), file.getAbsolutePath());
|
String[] commands = SystemExecHelper.buildCommands(ext, metaAction.getParams(), file.getAbsolutePath());
|
||||||
SystemExecResult execResult = SystemExecHelper.exec(commands);
|
SystemExecHelper.Result execResult = SystemExecHelper.exec(commands);
|
||||||
response.setOk(execResult.isOk());
|
response.setOk(execResult.isOk());
|
||||||
response.setData(execResult.getTotal());
|
response.setData(execResult.getTotal());
|
||||||
return response;
|
return response;
|
||||||
@@ -173,7 +173,7 @@ public class LocalRunnerClient extends RunnerClient {
|
|||||||
JSONObject sysDependencies = new JSONObject();
|
JSONObject sysDependencies = new JSONObject();
|
||||||
sysDependencies.put("language", "Python");
|
sysDependencies.put("language", "Python");
|
||||||
JSONArray dependencies = sysDependencies.putArray("dependencies");
|
JSONArray dependencies = sysDependencies.putArray("dependencies");
|
||||||
SystemExecResult pyResult = SystemExecHelper.exec("pip", "list", "--format=freeze");
|
SystemExecHelper.Result pyResult = SystemExecHelper.exec("pip", "list", "--format=freeze");
|
||||||
System.out.println(pyResult);
|
System.out.println(pyResult);
|
||||||
if (pyResult.isOk()) {
|
if (pyResult.isOk()) {
|
||||||
List<String> resultList = pyResult.getResultList();
|
List<String> resultList = pyResult.getResultList();
|
||||||
@@ -584,8 +584,8 @@ public class LocalRunnerClient extends RunnerClient {
|
|||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SystemExecResult exec(String... command) {
|
private static Result exec(String... command) {
|
||||||
SystemExecResult result = new SystemExecResult();
|
Result result = new Result();
|
||||||
List<String> output = new ArrayList<>();
|
List<String> output = new ArrayList<>();
|
||||||
List<String> error = new ArrayList<>();
|
List<String> error = new ArrayList<>();
|
||||||
|
|
||||||
@@ -635,12 +635,13 @@ public class LocalRunnerClient extends RunnerClient {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
private static class SystemExecResult {
|
private static class Result {
|
||||||
private boolean ok;
|
private boolean ok;
|
||||||
private String total;
|
private String total;
|
||||||
private List<String> resultList;
|
private List<String> resultList;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user