Helper enum constant for load entry point.

This commit is contained in:
Dmitry Trofimov
2015-08-04 18:45:59 +02:00
parent c8c56743c5
commit e4181c522b
3 changed files with 35 additions and 6 deletions
@@ -55,6 +55,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
private final Project myProject;
private Map<String, IpnbConnection> myKernels = new HashMap<String, IpnbConnection>();
private Map<String, IpnbCodePanel> myUpdateMap = new HashMap<String, IpnbCodePanel>();
public IpnbConnectionManager(final Project project) {
myProject = project;
}
@@ -191,7 +192,8 @@ public final class IpnbConnectionManager implements ProjectComponent {
}
catch (URISyntaxException e) {
if (showNotification) {
showWarning(codePanel.getFileEditor(), "Please, check IPython Notebook URL in <a href=\"\">Settings->Tools->IPython Notebook</a>",
showWarning(codePanel.getFileEditor(),
"Please, check IPython Notebook URL in <a href=\"\">Settings->Tools->IPython Notebook</a>",
new IpnbSettingsAdapter());
LOG.warn("IPython Notebook connection refused: " + e.getMessage());
}
@@ -271,8 +273,8 @@ public final class IpnbConnectionManager implements ProjectComponent {
new IpnbSettingsAdapter());
return false;
}
final String ipython = PythonHelpersLocator.getHelperPath("pycharm/pycharm_load_entry_point.py");
final ArrayList<String> parameters = Lists.newArrayList(sdk.getHomePath(), ipython, "notebook", "--no-browser");
final ArrayList<String> parameters = Lists.newArrayList("notebook", "--no-browser");
if (hostPort.getFirst() != null) {
parameters.add("--ip");
parameters.add(hostPort.getFirst());
@@ -281,8 +283,11 @@ public final class IpnbConnectionManager implements ProjectComponent {
parameters.add("--port");
parameters.add(hostPort.getSecond());
}
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters).withWorkDirectory(myProject.getBasePath()).
withEnvironment(env);
final GeneralCommandLine commandLine = PythonHelpersLocator.LOAD_ENTRY_POINT
.newCommandLine(sdk.getHomePath(), parameters)
.withWorkDirectory(myProject.getBasePath()).
withEnvironment(env);
try {
final KillableColoredProcessHandler processHandler = new KillableColoredProcessHandler(commandLine) {
@@ -343,7 +348,8 @@ public final class IpnbConnectionManager implements ProjectComponent {
}
}
public void projectOpened() {}
public void projectOpened() {
}
public void projectClosed() {
@@ -19,6 +19,7 @@ import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.ParamsGroup;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
/**
@@ -32,4 +33,6 @@ public interface PythonHelper {
void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd);
String asParamString();
GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters);
}
@@ -15,6 +15,7 @@
*/
package com.jetbrains.python;
import com.google.common.collect.Lists;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.ParamsGroup;
import com.intellij.openapi.application.PathManager;
@@ -26,6 +27,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.util.Map;
public enum PythonHelpersLocator implements PythonHelper {
@@ -35,6 +37,8 @@ public enum PythonHelpersLocator implements PythonHelper {
RUN_IN_CONSOLE("pydev", "pydev_run_in_console"),
PROFILER("profiler", "run_profiler"),
LOAD_ENTRY_POINT("pycharm", "pycharm_load_entry_point"),
// Test runners
UT("pycharm", "utrunner"),
SETUPPY("pycharm", "pycharm_setup_runner"),
@@ -151,6 +155,17 @@ public enum PythonHelpersLocator implements PythonHelper {
public String asParamString() {
return FileUtil.toSystemDependentName(myPath.getAbsolutePath());
}
@Override
public GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters) {
List<String> args = Lists.newArrayList();
args.add(sdkPath);
args.add(asParamString());
args.addAll(parameters);
GeneralCommandLine cmd = new GeneralCommandLine(args);
addToPythonPath(cmd.getEnvironment());
return cmd;
}
}
/**
@@ -218,4 +233,9 @@ public enum PythonHelpersLocator implements PythonHelper {
public String asParamString() {
return myModule.asParamString();
}
@Override
public GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters) {
return myModule.newCommandLine(sdkPath, parameters);
}
}