|
@@ -44,54 +44,6 @@ public class TrainFileModeService {
|
|
|
BlockingQueue<TrainInfo> console = new LinkedBlockingQueue<TrainInfo>();
|
|
|
|
|
|
|
|
|
- public synchronized void exec(TrainParam trainParam, MultipartFile file) throws Exception {
|
|
|
-
|
|
|
- //获取上传文件的文件名
|
|
|
- String type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
- ;
|
|
|
- /**上传文件**/
|
|
|
- //fileService.uploadFile(file.getOriginalFilename(), file.getInputStream(),"10.155.32.14");
|
|
|
-
|
|
|
- //文件路径
|
|
|
- String filePath = config.getPath() + file.getOriginalFilename();
|
|
|
-
|
|
|
- System.out.println(new Date() + "开始执行脚本...");
|
|
|
- Process p;
|
|
|
- String cmdPath = gyeeConfig.getDiagnosePath();
|
|
|
-
|
|
|
-
|
|
|
- try {
|
|
|
-// String[] cmd = {"/bin/sh", "-c", "python " + cmdPath + trainParam.getName() + ".py "+filePath};
|
|
|
- String cmd = "cmd /c python " + cmdPath + trainParam.getName() + ".py " + filePath;
|
|
|
-
|
|
|
-// System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
|
|
|
- p = Runtime.getRuntime().exec(cmd);
|
|
|
-
|
|
|
-
|
|
|
- BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
|
- BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream()));
|
|
|
- String si = null, se = null;
|
|
|
- while ((si = bri.readLine()) != null || (se = bre.readLine()) != null) {
|
|
|
- if (si != null) {
|
|
|
- System.out.println(si);
|
|
|
- }
|
|
|
- if (se != null) {
|
|
|
- System.out.println(se);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Thread.sleep(5000);
|
|
|
- p.waitFor();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- isComplete = true;
|
|
|
- }
|
|
|
- System.out.println(new Date() + "脚本执行结束...");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public synchronized void exec(String name, String forecastLabel, String[] inputLabel, String host, MultipartFile file) throws Exception {
|
|
|
|
|
|
if (!isComplete) {
|
|
@@ -113,10 +65,10 @@ public class TrainFileModeService {
|
|
|
|
|
|
|
|
|
try {
|
|
|
-// String[] cmd = {"/bin/sh", "-c", "python " + cmdPath + trainParam.getName() + ".py "+filePath};
|
|
|
- String cmd = "cmd /c python " + cmdPath + name + ".py " + filePath;
|
|
|
+ String[] cmd = {"/bin/sh", "-c", "python " + cmdPath + name + ".py " + filePath};
|
|
|
+// String cmd = "cmd /c python " + cmdPath + name + ".py " + filePath;
|
|
|
|
|
|
-// System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
|
|
|
+ System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
|
|
|
p = Runtime.getRuntime().exec(cmd);
|
|
|
|
|
|
|