PythonInterpreter extends Interpreter { @Override public InterpreterResult interpret(String st, InterpreterContext context) throws InterpreterException { if (iPythonInterpreter != null) { return iPythonInterpreter.interpret(st, context); } outputStream.setInterpreterOutput(context.out); ZeppelinContext z = getZeppelinContext(); z.setInterpreterContext(context); z.setGui(context.getGui()); z.setNoteGui(context.getNoteGui()); InterpreterContext.set(context); preCallPython(context); callPython(new PythonInterpretRequest(st, false)); if (statementError) { return new InterpreterResult(Code.ERROR, statementOutput); } else { try { context.out.flush(); } catch (IOException e) { throw new InterpreterException(e); } if (pythonProcessLauncher.isRunning()) { return new InterpreterResult(Code.SUCCESS); } else { return new InterpreterResult(Code.ERROR, "Python process is abnormally exited, please check your code and log."); } } } PythonInterpreter(Properties property); @Override void open(); PythonProcessLauncher getPythonProcessLauncher(); File getPythonWorkDir(); @Override void close(); void setPythonExec(String pythonExec); PythonInterpretRequest getStatements(); void setStatementsFinished(String out, boolean error); void onPythonScriptInitialized(long pid); void appendOutput(String message); @Override InterpreterResult interpret(String st, InterpreterContext context); void interrupt(); @Override void cancel(InterpreterContext context); @Override FormType getFormType(); @Override int getProgress(InterpreterContext context); @Override List<InterpreterCompletion> completion(String buf, int cursor,
                                                InterpreterContext interpreterContext); ZeppelinContext getZeppelinContext(); void logPythonOutput(String message);  }
@Test public void testFailtoLaunchPythonProcess() throws InterpreterException { tearDown(); intpGroup = new InterpreterGroup(); Properties properties = new Properties(); properties.setProperty("zeppelin.python", "invalid_python"); properties.setProperty("zeppelin.python.useIPython", "false"); properties.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1"); interpreter = new LazyOpenInterpreter(new PythonInterpreter(properties)); intpGroup.put("note", new LinkedList<Interpreter>()); intpGroup.get("note").add(interpreter); interpreter.setInterpreterGroup(intpGroup); InterpreterContext.set(getInterpreterContext()); try { interpreter.interpret("1+1", getInterpreterContext()); fail("Should fail to open PythonInterpreter"); } catch (InterpreterException e) { String stacktrace = ExceptionUtils.getStackTrace(e); assertTrue(stacktrace, stacktrace.contains("No such file or directory")); } }