Search in sources :

Example 1 with ConsoleCommunicationListener

use of com.jetbrains.python.console.pydev.ConsoleCommunicationListener in project intellij-community by JetBrains.

the class PythonConsoleView method showVariables.

public void showVariables(PydevConsoleCommunication consoleCommunication) {
    PyStackFrame stackFrame = new PyStackFrame(getProject(), consoleCommunication, new PyStackFrameInfo("", "", "", null), null);
    final XStandaloneVariablesView view = new XStandaloneVariablesView(getProject(), new PyDebuggerEditorsProvider(), stackFrame);
    consoleCommunication.addCommunicationListener(new ConsoleCommunicationListener() {

        @Override
        public void commandExecuted(boolean more) {
            view.rebuildView();
        }

        @Override
        public void inputRequested() {
        }
    });
    mySplitView = view;
    Disposer.register(this, view);
    splitWindow();
}
Also used : XStandaloneVariablesView(com.intellij.xdebugger.impl.frame.XStandaloneVariablesView) PyStackFrame(com.jetbrains.python.debugger.PyStackFrame) PyDebuggerEditorsProvider(com.jetbrains.python.debugger.PyDebuggerEditorsProvider) ConsoleCommunicationListener(com.jetbrains.python.console.pydev.ConsoleCommunicationListener) PyStackFrameInfo(com.jetbrains.python.debugger.PyStackFrameInfo)

Example 2 with ConsoleCommunicationListener

use of com.jetbrains.python.console.pydev.ConsoleCommunicationListener in project intellij-community by JetBrains.

the class PydevConsoleRunnerImpl method connectToDebugger.

private XDebugSession connectToDebugger() throws ExecutionException {
    final ServerSocket serverSocket = PythonCommandLineState.createServerSocket();
    final XDebugSession session = XDebuggerManager.getInstance(myProject).startSessionAndShowTab("Python Console Debugger", PythonIcons.Python.Python, null, true, new XDebugProcessStarter() {

        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
            PythonDebugLanguageConsoleView debugConsoleView = new PythonDebugLanguageConsoleView(myProject, mySdk);
            PyConsoleDebugProcessHandler consoleDebugProcessHandler = new PyConsoleDebugProcessHandler(myProcessHandler);
            PyConsoleDebugProcess consoleDebugProcess = new PyConsoleDebugProcess(session, serverSocket, debugConsoleView, consoleDebugProcessHandler);
            PythonDebugConsoleCommunication communication = PyDebugRunner.initDebugConsoleView(myProject, consoleDebugProcess, debugConsoleView, consoleDebugProcessHandler, session);
            communication.addCommunicationListener(new ConsoleCommunicationListener() {

                @Override
                public void commandExecuted(boolean more) {
                    session.rebuildViews();
                }

                @Override
                public void inputRequested() {
                }
            });
            myPydevConsoleCommunication.setDebugCommunication(communication);
            debugConsoleView.attachToProcess(consoleDebugProcessHandler);
            consoleDebugProcess.waitForNextConnection();
            try {
                consoleDebugProcess.connect(myPydevConsoleCommunication);
            } catch (Exception e) {
                //TODO
                LOG.error(e);
            }
            myProcessHandler.notifyTextAvailable("\nDebugger connected.\n", ProcessOutputTypes.STDERR);
            return consoleDebugProcess;
        }
    });
    return session;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugProcess(com.intellij.xdebugger.XDebugProcess) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ConsoleCommunicationListener(com.jetbrains.python.console.pydev.ConsoleCommunicationListener) ServerSocket(java.net.ServerSocket) NotNull(org.jetbrains.annotations.NotNull) XmlRpcException(org.apache.xmlrpc.XmlRpcException) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException)

Example 3 with ConsoleCommunicationListener

use of com.jetbrains.python.console.pydev.ConsoleCommunicationListener in project intellij-community by JetBrains.

the class PyDebugRunner method initDebugConsoleView.

public static PythonDebugConsoleCommunication initDebugConsoleView(Project project, PyDebugProcess debugProcess, PythonDebugLanguageConsoleView console, ProcessHandler processHandler, final XDebugSession session) {
    PythonConsoleView pythonConsoleView = console.getPydevConsoleView();
    PythonDebugConsoleCommunication debugConsoleCommunication = new PythonDebugConsoleCommunication(project, debugProcess);
    pythonConsoleView.setConsoleCommunication(debugConsoleCommunication);
    PydevDebugConsoleExecuteActionHandler consoleExecuteActionHandler = new PydevDebugConsoleExecuteActionHandler(pythonConsoleView, processHandler, debugConsoleCommunication);
    pythonConsoleView.setExecutionHandler(consoleExecuteActionHandler);
    debugProcess.getSession().addSessionListener(consoleExecuteActionHandler);
    new LanguageConsoleBuilder(pythonConsoleView).processHandler(processHandler).initActions(consoleExecuteActionHandler, "py");
    debugConsoleCommunication.addCommunicationListener(new ConsoleCommunicationListener() {

        @Override
        public void commandExecuted(boolean more) {
            session.rebuildViews();
        }

        @Override
        public void inputRequested() {
        }
    });
    return debugConsoleCommunication;
}
Also used : ConsoleCommunicationListener(com.jetbrains.python.console.pydev.ConsoleCommunicationListener) PythonConsoleView(com.jetbrains.python.console.PythonConsoleView) PythonDebugConsoleCommunication(com.jetbrains.python.console.PythonDebugConsoleCommunication) LanguageConsoleBuilder(com.intellij.execution.console.LanguageConsoleBuilder)

Example 4 with ConsoleCommunicationListener

use of com.jetbrains.python.console.pydev.ConsoleCommunicationListener in project intellij-community by JetBrains.

the class PyConsoleTask method runTestOn.

@Override
public void runTestOn(final String sdkHome) throws Exception {
    final Project project = getProject();
    final Sdk sdk = createTempSdk(sdkHome, SdkCreationType.EMPTY_SDK);
    setProcessCanTerminate(false);
    PydevConsoleRunner consoleRunner = new PydevConsoleRunnerImpl(project, sdk, PyConsoleType.PYTHON, myFixture.getTempDirPath(), Maps.newHashMap(), PyConsoleOptions.getInstance(project).getPythonConsoleSettings(), (s) -> {
    });
    before();
    myConsoleInitSemaphore = new Semaphore(0);
    consoleRunner.addConsoleListener(new PydevConsoleRunnerImpl.ConsoleListener() {

        @Override
        public void handleConsoleInitialized(LanguageConsoleView consoleView) {
            myConsoleInitSemaphore.release();
        }
    });
    consoleRunner.run();
    waitFor(myConsoleInitSemaphore);
    myCommandSemaphore = new Semaphore(1);
    myConsoleView = consoleRunner.getConsoleView();
    myProcessHandler = consoleRunner.getProcessHandler();
    myExecuteHandler = consoleRunner.getConsoleExecuteActionHandler();
    myCommunication = consoleRunner.getPydevConsoleCommunication();
    myCommunication.addCommunicationListener(new ConsoleCommunicationListener() {

        @Override
        public void commandExecuted(boolean more) {
            myCommandSemaphore.release();
        }

        @Override
        public void inputRequested() {
        }
    });
    myProcessHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            if (event.getExitCode() != 0 && !myProcessCanTerminate) {
                Assert.fail("Process terminated unexpectedly\n" + output());
            }
        }
    });
    OutputPrinter myOutputPrinter = null;
    if (shouldPrintOutput) {
        myOutputPrinter = new OutputPrinter();
        myOutputPrinter.start();
    }
    waitForOutput("PyDev console");
    try {
        testing();
        after();
    } finally {
        setProcessCanTerminate(true);
        if (myOutputPrinter != null) {
            myOutputPrinter.stop();
        }
        disposeConsole();
    }
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) ProcessEvent(com.intellij.execution.process.ProcessEvent) Semaphore(java.util.concurrent.Semaphore) Project(com.intellij.openapi.project.Project) ConsoleCommunicationListener(com.jetbrains.python.console.pydev.ConsoleCommunicationListener) Sdk(com.intellij.openapi.projectRoots.Sdk)

Aggregations

ConsoleCommunicationListener (com.jetbrains.python.console.pydev.ConsoleCommunicationListener)4 ExecutionException (com.intellij.execution.ExecutionException)1 LanguageConsoleBuilder (com.intellij.execution.console.LanguageConsoleBuilder)1 LanguageConsoleView (com.intellij.execution.console.LanguageConsoleView)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 XDebugProcess (com.intellij.xdebugger.XDebugProcess)1 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 XStandaloneVariablesView (com.intellij.xdebugger.impl.frame.XStandaloneVariablesView)1 PythonConsoleView (com.jetbrains.python.console.PythonConsoleView)1 PythonDebugConsoleCommunication (com.jetbrains.python.console.PythonDebugConsoleCommunication)1 PyDebuggerEditorsProvider (com.jetbrains.python.debugger.PyDebuggerEditorsProvider)1 PyStackFrame (com.jetbrains.python.debugger.PyStackFrame)1 PyStackFrameInfo (com.jetbrains.python.debugger.PyStackFrameInfo)1 IOException (java.io.IOException)1 ServerSocket (java.net.ServerSocket)1 Semaphore (java.util.concurrent.Semaphore)1