diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterhubController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterhubController.java index e81a606..1ebc1cc 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterhubController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterhubController.java @@ -79,12 +79,13 @@ public class JupyterhubController { //存储文件路径 String path = "/etc/jupyterhub/data/"; + //etc/jupyterhub/data/xxx/ String newCreatFile = path + caseName+"/"; File dataFile = new File(newCreatFile); - + System.out.println("1111111111"+dataFile); //判断文件夹是否存在 if (!dataFile.exists()) { dataFile.mkdirs(); @@ -95,6 +96,7 @@ public class JupyterhubController { File myFile = new File(fileResource); + System.out.println("222222222222"+myFile); // 判断文件是否存在 if (myFile.exists()) { @@ -106,6 +108,7 @@ public class JupyterhubController { // 创建一个新的进程来执行Python代码 Process process = Runtime.getRuntime().exec(command); + System.out.println("开始执行命令: " + command); // 获取进程的输入流 BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); @@ -157,13 +160,27 @@ public class JupyterhubController { ///etc/jupyterhub/data/xxx/ String pathIpynb = newCreatFile + caseName + ".ipynb"; + System.out.println("3333333"+pathIpynb); File file1 = new File(pathIpynb); if (!file1.exists()) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "Ipynb文件不存在!"); - } + //判断数据集是否存在 + + String sonPath = newCreatFile + "/data/"; + if (new File(sonPath).exists()) { + return new ResultEntity<>(HttpStatus.OK, "数据存在!", true); + }else { + return new ResultEntity<>(HttpStatus.OK, "Ipynb文件不存在!",false); + } + } + return new ResultEntity<>(HttpStatus.OK, "数据存在!", true); } + + + + + System.out.println("44444444444444444444444失败"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "数据异常!", false); } @@ -368,7 +385,7 @@ public class JupyterhubController { File file = new File(filepath); if (file.exists()) { //重命名 - + System.out.println(" code output:\n" + "3333333改名成功"); // 新文件或目录路径 String newPath = "/etc/jupyterhub/data/" + newName + ".ipynb"; // 请将此路径替换为实际路径 @@ -378,12 +395,24 @@ public class JupyterhubController { // 重命名文件或目录 boolean success = oldFile.renameTo(newFile); - + System.out.println(" code output:\n" + "改名成功"); return new ResultEntity<>(HttpStatus.OK, success); } else { - return new ResultEntity<>(HttpStatus.OK, "重命名失败!", false); + String fileDataPath = "/etc/jupyterhub/data/"+caseName+"/" + caseName + ".ipynb"; + String newDataPath = "/etc/jupyterhub/data/"+newName+"/" + newName + ".ipynb"; + // 创建 File 对象 + File oldFile = new File(fileDataPath); + File newFile = new File(newDataPath); + // 重命名文件或目录 + System.out.println(" code output:\n" + "32423改名成功"); + boolean success = oldFile.renameTo(newFile); + + //文件移动到另一个文件夹 + System.out.println(" code output:\n" + "改名成功"); + return new ResultEntity<>(HttpStatus.OK, success); + } }