Search in sources :

Example 1 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class GroovyConsole method createProcessHandler.

private static ProcessHandler createProcessHandler(Module module) {
    try {
        final JavaParameters javaParameters = createJavaParameters(module);
        final GeneralCommandLine commandLine = javaParameters.toCommandLine();
        return new OSProcessHandler(commandLine) {

            @Override
            public boolean isSilentlyDestroyOnClose() {
                return true;
            }
        };
    } catch (ExecutionException e) {
        LOG.warn(e);
        return null;
    }
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) JavaParameters(com.intellij.execution.configurations.JavaParameters) ExecutionException(com.intellij.execution.ExecutionException)

Example 2 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class CommandExecutor method start.

public void start() throws SvnBindException {
    synchronized (myLock) {
        checkNotStarted();
        try {
            beforeCreateProcess();
            myProcess = createProcess();
            if (LOG.isDebugEnabled()) {
                LOG.debug(myCommandLine.toString());
            }
            myHandler = createProcessHandler();
            myProcessWriter = new OutputStreamWriter(myHandler.getProcessInput());
            startHandlingStreams();
        } catch (ExecutionException e) {
            // TODO: currently startFailed() is not used for some real logic in svn4idea plugin
            listeners().startFailed(e);
            throw new SvnBindException(e);
        }
    }
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) ExecutionException(com.intellij.execution.ExecutionException)

Example 3 with ExecutionException

use of com.intellij.execution.ExecutionException 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 4 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class PydevConsoleRunnerImpl method createRemoteConsoleProcess.

private RemoteProcess createRemoteConsoleProcess(PythonRemoteInterpreterManager manager, String[] command, Map<String, String> env, File workDirectory) throws ExecutionException {
    PyRemoteSdkAdditionalDataBase data = (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData();
    assert data != null;
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(workDirectory);
    commandLine.withParameters(command);
    commandLine.getEnvironment().putAll(env);
    commandLine.getParametersList().set(0, PythonRemoteInterpreterManager.toSystemDependent(new File(data.getHelpersPath(), getRunnerFileFromHelpers()).getPath(), PySourcePosition.isWindowsPath(data.getInterpreterPath())));
    commandLine.getParametersList().set(1, "0");
    commandLine.getParametersList().set(2, "0");
    try {
        PyRemotePathMapper pathMapper = PydevConsoleRunner.getPathMapper(myProject, mySdk, myConsoleSettings);
        assert pathMapper != null;
        commandLine.putUserData(PyRemoteProcessStarter.OPEN_FOR_INCOMING_CONNECTION, true);
        // we do not have an option to setup Docker container settings now for Python console so we should bind at least project
        // directory to some path inside the Docker container
        commandLine.putUserData(PythonRemoteInterpreterManager.ADDITIONAL_MAPPINGS, buildDockerPathMappings());
        myRemoteProcessHandlerBase = PyRemoteProcessStarterManagerUtil.getManager(data).startRemoteProcess(myProject, commandLine, manager, data, pathMapper);
        myCommandLine = myRemoteProcessHandlerBase.getCommandLine();
        RemoteProcess remoteProcess = myRemoteProcessHandlerBase.getProcess();
        Couple<Integer> remotePorts = getRemotePortsFromProcess(remoteProcess);
        if (remoteProcess instanceof Tunnelable) {
            Tunnelable tunnelableProcess = (Tunnelable) remoteProcess;
            tunnelableProcess.addLocalTunnel(myPorts[0], remotePorts.first);
            tunnelableProcess.addRemoteTunnel(remotePorts.second, "localhost", myPorts[1]);
            if (LOG.isDebugEnabled()) {
                LOG.debug(String.format("Using tunneled communication for Python console: port %d (=> %d) on IDE side, " + "port %d (=> %d) on pydevconsole.py side", myPorts[1], remotePorts.second, myPorts[0], remotePorts.first));
            }
            myPydevConsoleCommunication = new PydevRemoteConsoleCommunication(myProject, myPorts[0], remoteProcess, myPorts[1]);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug(String.format("Using direct communication for Python console: port %d on IDE side, port %d on pydevconsole.py side", remotePorts.second, remotePorts.first));
            }
            myPydevConsoleCommunication = new PydevRemoteConsoleCommunication(myProject, remotePorts.first, remoteProcess, remotePorts.second);
        }
        return remoteProcess;
    } catch (Exception e) {
        throw new ExecutionException(e.getMessage(), e);
    }
}
Also used : PyRemotePathMapper(com.jetbrains.python.remote.PyRemotePathMapper) Tunnelable(com.intellij.remote.Tunnelable) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) PyRemoteSdkAdditionalDataBase(com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase) RemoteProcess(com.intellij.remote.RemoteProcess) ExecutionException(com.intellij.execution.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile) XmlRpcException(org.apache.xmlrpc.XmlRpcException) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException)

Example 5 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class PydevConsoleRunnerImpl method createProcess.

private Process createProcess() throws ExecutionException {
    if (PySdkUtil.isRemote(mySdk)) {
        PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
        if (manager != null) {
            UsageTrigger.trigger(CONSOLE_FEATURE + ".remote");
            return createRemoteConsoleProcess(manager, myGeneralCommandLine.getParametersList().getArray(), myGeneralCommandLine.getEnvironment(), myGeneralCommandLine.getWorkDirectory());
        }
        throw new PythonRemoteInterpreterManager.PyRemoteInterpreterExecutionException();
    } else {
        myCommandLine = myGeneralCommandLine.getCommandLineString();
        Map<String, String> envs = myGeneralCommandLine.getEnvironment();
        EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(envs, myGeneralCommandLine.getCharset());
        UsageTrigger.trigger(CONSOLE_FEATURE + ".local");
        final Process server = myGeneralCommandLine.createProcess();
        try {
            myPydevConsoleCommunication = new PydevConsoleCommunication(myProject, myPorts[0], server, myPorts[1]);
        } catch (Exception e) {
            throw new ExecutionException(e.getMessage());
        }
        return server;
    }
}
Also used : RemoteProcess(com.intellij.remote.RemoteProcess) XDebugProcess(com.intellij.xdebugger.XDebugProcess) ExecutionException(com.intellij.execution.ExecutionException) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager) XmlRpcException(org.apache.xmlrpc.XmlRpcException) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)230 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)68 NotNull (org.jetbrains.annotations.NotNull)57 File (java.io.File)52 IOException (java.io.IOException)47 VirtualFile (com.intellij.openapi.vfs.VirtualFile)40 Project (com.intellij.openapi.project.Project)35 Nullable (org.jetbrains.annotations.Nullable)34 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)26 ProcessOutput (com.intellij.execution.process.ProcessOutput)24 Sdk (com.intellij.openapi.projectRoots.Sdk)23 Key (com.intellij.openapi.util.Key)23 ProcessEvent (com.intellij.execution.process.ProcessEvent)22 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)21 Module (com.intellij.openapi.module.Module)21 ProcessHandler (com.intellij.execution.process.ProcessHandler)20 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)17 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)17 CapturingProcessHandler (com.intellij.execution.process.CapturingProcessHandler)10 Executor (com.intellij.execution.Executor)9