make z.getInterpreterContext().out().clear() work in PythonInterpreter

This commit is contained in:
Lee moon soo 2018-03-02 16:50:22 -08:00
parent 21dc20d886
commit 224a2df8e6
3 changed files with 8 additions and 1 deletions

View file

@ -388,6 +388,7 @@ public class PythonInterpreter extends Interpreter implements ExecuteResultHandl
zeppelinContext.setGui(context.getGui());
zeppelinContext.setNoteGui(context.getNoteGui());
zeppelinContext.setInterpreterContext(context);
if (!pythonscriptRunning) {
return new InterpreterResult(Code.ERROR, "python process not running"

View file

@ -61,7 +61,7 @@ class PyZeppelinContext(object):
self._setup_matplotlib()
def getInterpreterContext(self):
return self.z.getCurrentInterpreterContext()
return self.z.getInterpreterContext()
def input(self, name, defaultValue=""):
return self.z.input(name, defaultValue)

View file

@ -123,6 +123,12 @@ public class PythonInterpreterTest implements InterpreterOutputListener {
assertEquals(InterpreterResult.Code.SUCCESS, pythonInterpreter.interpret(pyValidCode, context).code());
}
@Test
public void testOutputClear() throws InterpreterException {
InterpreterResult result = pythonInterpreter.interpret("print(\"Hello\")\nz.getInterpreterContext().out().clear()\nprint(\"world\")\n", context);
assertEquals("%text world\n", out.getCurrentOutput().toString());
}
@Override
public void onUpdateAll(InterpreterOutput out) {