use of com.jetbrains.python.console.pydev.InterpreterResponse in project intellij-community by JetBrains.
the class PythonDebugConsoleCommunication method execInterpreter.
public void execInterpreter(ConsoleCodeFragment code, final Function<InterpreterResponse, Object> callback) {
if (waitingForInput) {
final OutputStream processInput = myDebugProcess.getProcessHandler().getProcessInput();
if (processInput != null) {
try {
final Charset defaultCharset = EncodingProjectManager.getInstance(myDebugProcess.getProject()).getDefaultCharset();
processInput.write((code.getText()).getBytes(defaultCharset));
processInput.flush();
} catch (IOException e) {
LOG.error(e.getMessage());
}
}
myNeedsMore = false;
waitingForInput = false;
notifyCommandExecuted(waitingForInput);
} else {
exec(new ConsoleCodeFragment(code.getText(), false), new PyDebugCallback<Pair<String, Boolean>>() {
@Override
public void ok(Pair<String, Boolean> executed) {
boolean more = executed.second;
myNeedsMore = more;
notifyCommandExecuted(more);
callback.fun(new InterpreterResponse(more, isWaitingForInput()));
}
@Override
public void error(PyDebuggerException exception) {
myNeedsMore = false;
notifyCommandExecuted(false);
callback.fun(new InterpreterResponse(false, isWaitingForInput()));
}
});
}
}
Aggregations