Support running Python console in Docker container.

This commit is contained in:
Dmitry Trofimov
2015-10-02 14:24:58 +02:00
parent c2366d4dc4
commit 950b10cc8b
5 changed files with 47 additions and 22 deletions
@@ -24,15 +24,4 @@ public abstract class RemoteProcess extends Process implements SelfKiller {
public abstract boolean killProcessTree();
public abstract boolean isDisconnected();
/**
* Makes host:localPort server which is available on local side available on remote side as localhost:remotePort.
*/
public abstract void addRemoteTunnel(int remotePort, String host, int localPort) throws RemoteSdkException;
/**
* Makes host:remotePort server which is available on remote side available on local side as localhost:localPort.
*/
public abstract void addLocalTunnel(int localPort, String host, int remotePort) throws RemoteSdkException;
}
@@ -5,7 +5,7 @@ import com.intellij.execution.process.SelfKiller;
/**
* @author traff
*/
abstract public class RemoteSshProcess extends RemoteProcess implements SelfKiller {
abstract public class RemoteSshProcess extends RemoteProcess implements SelfKiller, Tunnelable {
/**
* @deprecated use {@link #killProcessTree()}
*/
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remote;
/**
* @author traff
*/
public interface Tunnelable {
/**
* Makes host:localPort server which is available on local side available on remote side as localhost:remotePort.
*/
void addRemoteTunnel(int remotePort, String host, int localPort) throws RemoteSdkException;
/**
* Makes host:remotePort server which is available on remote side available on local side as localhost:localPort.
*/
void addLocalTunnel(int localPort, int remotePort) throws RemoteSdkException;
}
@@ -67,6 +67,7 @@ import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.remote.RemoteProcess;
import com.intellij.remote.Tunnelable;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
@@ -87,10 +88,7 @@ import com.jetbrains.python.remote.PyRemotePathMapper;
import com.jetbrains.python.remote.PyRemoteProcessHandlerBase;
import com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase;
import com.jetbrains.python.remote.PythonRemoteInterpreterManager;
import com.jetbrains.python.run.PyRemoteProcessStarterManagerUtil;
import com.jetbrains.python.run.PythonCommandLineState;
import com.jetbrains.python.run.PythonRunParams;
import com.jetbrains.python.run.PythonTracebackFilter;
import com.jetbrains.python.run.*;
import com.jetbrains.python.sdk.PySdkUtil;
import com.jetbrains.python.sdk.PythonSdkType;
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
@@ -481,11 +479,12 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
try {
PyRemotePathMapper pathMapper = manager.setupMappings(getProject(), data, null);
//TODO
//commandLine.withExePath(myRemoteCredentials.getFullInterpreterPath());
commandLine.withExePath(data.getInterpreterPath()); //TODO: set getFullInterpreterPath() instead
myCommandLine = commandLine.getCommandLineString();
commandLine.putUserData(PyRemoteProcessStarter.OPEN_FOR_INCOMING_CONNECTION, true);
myRemoteProcessHandlerBase = PyRemoteProcessStarterManagerUtil
.getManager(data).startRemoteProcess(getProject(), commandLine, manager, data,
pathMapper);
@@ -494,15 +493,17 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
Couple<Integer> remotePorts = getRemotePortsFromProcess(remoteProcess);
//remoteProcess.addLocalTunnel(myPorts[0], myRemoteCredentials.getHost(), remotePorts.first);
remoteProcess.addRemoteTunnel(remotePorts.second, "localhost", myPorts[1]);
if (remoteProcess instanceof Tunnelable) {
Tunnelable tunnelableProcess = (Tunnelable) remoteProcess;
tunnelableProcess.addLocalTunnel(myPorts[0], remotePorts.first);
tunnelableProcess.addRemoteTunnel(remotePorts.second, "localhost", myPorts[1]);
}
myPydevConsoleCommunication = new PydevRemoteConsoleCommunication(getProject(), myPorts[0], remoteProcess, myPorts[1]);
return remoteProcess;
}
catch (Exception e) {
throw new ExecutionException(e.getMessage());
throw new ExecutionException(e.getMessage(), e);
}
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkAdditionalData;
import com.intellij.openapi.util.Key;
import com.jetbrains.python.remote.PyRemotePathMapper;
import com.jetbrains.python.remote.PyRemoteProcessHandlerBase;
import com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase;
@@ -35,6 +36,8 @@ import org.jetbrains.annotations.Nullable;
* @author traff
*/
public class PyRemoteProcessStarter {
public static final Key<Boolean> OPEN_FOR_INCOMING_CONNECTION = Key.create("OPEN_FOR_INCOMING_CONNECTION");
public ProcessHandler startRemoteProcess(@NotNull Sdk sdk,
@NotNull GeneralCommandLine commandLine,
@Nullable Project project,