this.naturesUsed = naturesUsed;
Integer[] ports = SocketUtil.findUnusedLocalPorts(2);
int port = ports[0];
int clientPort = ports[1];
final Launch launch = new Launch(createLaunchConfig(), "interactive", null);
launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "false");
launch.setAttribute(INTERACTIVE_LAUNCH_PORT, "" + port);
File scriptWithinPySrc = PydevPlugin.getScriptWithinPySrc("pydevconsole.py");
Collection<String> extraPath = pythonpath;
if (InteractiveConsolePrefs.getConsoleConnectVariableView()
&& interpreterManager.getInterpreterType() != IInterpreterManager.INTERPRETER_TYPE_JYTHON_ECLIPSE) {
// Add PydevDebugPlugin's pysrc so we can access pydevd
extraPath = new LinkedHashSet<String>();
extraPath.add(PydevDebugPlugin.getPySrcPath().getAbsolutePath()); //Add this one as the first in the PYTHONPATH!
extraPath.addAll(pythonpath);
}
String pythonpathEnv = SimpleRunner.makePythonPathEnvFromPaths(extraPath);
String[] commandLine;
switch (interpreterManager.getInterpreterType()) {
case IInterpreterManager.INTERPRETER_TYPE_PYTHON:
commandLine = SimplePythonRunner.makeExecutableCommandStr(interpreter.getExecutableOrJar(),
scriptWithinPySrc.getAbsolutePath(),
new String[] { String.valueOf(port), String.valueOf(clientPort) });
break;
case IInterpreterManager.INTERPRETER_TYPE_IRONPYTHON:
commandLine = SimpleIronpythonRunner.makeExecutableCommandStr(interpreter.getExecutableOrJar(),
scriptWithinPySrc.getAbsolutePath(),
new String[] { String.valueOf(port), String.valueOf(clientPort) });
break;
case IInterpreterManager.INTERPRETER_TYPE_JYTHON:
String vmArgs = PydevDebugPlugin.getDefault().getPreferenceStore()
.getString(PydevConsoleConstants.INTERACTIVE_CONSOLE_VM_ARGS);
commandLine = SimpleJythonRunner.makeExecutableCommandStrWithVMArgs(interpreter.getExecutableOrJar(),
scriptWithinPySrc.getAbsolutePath(), pythonpathEnv, vmArgs, new String[] {
String.valueOf(port), String.valueOf(clientPort) });
break;
case IInterpreterManager.INTERPRETER_TYPE_JYTHON_ECLIPSE:
commandLine = null;
break;
default:
throw new RuntimeException(
"Expected interpreter manager to be python or jython or iron python related.");
}
if (interpreterManager.getInterpreterType() == IInterpreterManager.INTERPRETER_TYPE_JYTHON_ECLIPSE) {
process = new JythonEclipseProcess(scriptWithinPySrc.getAbsolutePath(), port, clientPort);
} else {
String[] env = SimpleRunner.createEnvWithPythonpath(pythonpathEnv, interpreter.getExecutableOrJar(),
interpreterManager, nature);
process = SimpleRunner.createProcess(commandLine, env, null);
}
IProcess newProcess = new PydevSpawnedInterpreterProcess(launch, process, interpreter.getNameForUI(), null);
launch.addProcess(newProcess);
return new PydevConsoleLaunchInfo(launch, process, clientPort, interpreter, null);
}