private Process createRemoteConsoleProcess( PythonRemoteInterpreterManager manager, String[] command, Map<String, String> env) throws ExecutionException { PyRemoteSdkAdditionalDataBase data = (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData(); assert data != null; GeneralCommandLine commandLine = new GeneralCommandLine(command); commandLine.getEnvironment().putAll(env); commandLine .getParametersList() .set( 1, PythonRemoteInterpreterManager.toSystemDependent( new File(data.getHelpersPath(), PYDEV_PYDEVCONSOLE_PY).getPath(), PySourcePosition.isWindowsPath(data.getInterpreterPath()))); commandLine.getParametersList().set(2, "0"); commandLine.getParametersList().set(3, "0"); myCommandLine = commandLine.getCommandLineString(); try { myRemoteCredentials = data.getRemoteSdkCredentials(true); PathMappingSettings mappings = manager.setupMappings(getProject(), data, null); RemoteSshProcess remoteProcess = manager.createRemoteProcess( getProject(), myRemoteCredentials, mappings, commandLine, true); Couple<Integer> remotePorts = getRemotePortsFromProcess(remoteProcess); remoteProcess.addLocalTunnel(myPorts[0], myRemoteCredentials.getHost(), remotePorts.first); remoteProcess.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()); } }
private static Couple<Integer> getRemotePortsFromProcess(RemoteSshProcess process) throws ExecutionException { Scanner s = new Scanner(process.getInputStream()); return Couple.of(readInt(s, process), readInt(s, process)); }