yx91490 commented on a change in pull request #3287: IPythonInterpreter delete 
temp file and close stream
URL: https://github.com/apache/zeppelin/pull/3287#discussion_r250476768
 
 

 ##########
 File path: 
python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java
 ##########
 @@ -161,38 +161,46 @@ public void open() throws InterpreterException {
    */
   public String checkIPythonPrerequisite(String pythonExec) {
     ProcessBuilder processBuilder = new ProcessBuilder(pythonExec, "-m", 
"pip", "freeze");
+    File stderrFile = null;
+    File stdoutFile = null;
     try {
-      File stderrFile = File.createTempFile("zeppelin", ".txt");
+      stderrFile = File.createTempFile("zeppelin", ".txt");
       processBuilder.redirectError(stderrFile);
-      File stdoutFile = File.createTempFile("zeppelin", ".txt");
+      stdoutFile = File.createTempFile("zeppelin", ".txt");
       processBuilder.redirectOutput(stdoutFile);
 
       Process proc = processBuilder.start();
       int ret = proc.waitFor();
       if (ret != 0) {
-        return "Fail to run pip freeze.\n" +
-            IOUtils.toString(new FileInputStream(stderrFile));
-      }
-      String freezeOutput = IOUtils.toString(new FileInputStream(stdoutFile));
-      if (!freezeOutput.contains("jupyter-client=")) {
-        return "jupyter-client is not installed.";
-      }
-      if (!freezeOutput.contains("ipykernel=")) {
-        return "ipykernel is not installed";
-      }
-      if (!freezeOutput.contains("ipython=")) {
-        return "ipython is not installed";
-      }
-      if (!freezeOutput.contains("grpcio=")) {
-        return "grpcio is not installed";
+        try (FileInputStream in = new FileInputStream(stderrFile)) {
+          return "Fail to run pip freeze.\n" + IOUtils.toString(in);
+        }
 
 Review comment:
   yes

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to