diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbFileType.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbFileType.java index dd3002a3431d..369823a17515 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbFileType.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbFileType.java @@ -38,7 +38,7 @@ public class IpnbFileType implements FileType { @NotNull public String getDescription() { - return "IPython Notebook"; + return "Jupyter Notebook"; } @NotNull diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.form b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.form index 5f6842a4a839..eafa9034f2d3 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.form +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.form @@ -21,7 +21,7 @@ - + diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.java index d1817594e83f..31d2654cb61f 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConfigurable.java @@ -23,7 +23,7 @@ public class IpnbConfigurable implements SearchableConfigurable { @Nls @Override public String getDisplayName() { - return "IPython Notebook"; + return "Jupyter Notebook"; } @Override diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java index 0fb544970509..2cdad2f5824c 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java @@ -125,7 +125,7 @@ public final class IpnbConnectionManager implements ProjectComponent { @Nullable public static String showDialogUrl(@NotNull final String initialUrl) { - final String url = Messages.showInputDialog("IPython Notebook URL:", "Start IPython Notebook", null, initialUrl, + final String url = Messages.showInputDialog("Jupyter Notebook URL:", "Start Jupyter Notebook", null, initialUrl, new InputValidator() { @Override public boolean checkInput(String inputString) { @@ -195,16 +195,16 @@ public final class IpnbConnectionManager implements ProjectComponent { catch (URISyntaxException e) { if (showNotification && codePanel != null) { showWarning(codePanel.getFileEditor(), - "Please, check IPython Notebook URL in Settings->Tools->IPython Notebook", + "Please, check Jupyter Notebook URL in Settings->Tools->Jupyter Notebook", new IpnbSettingsAdapter()); - LOG.warn("IPython Notebook connection refused: " + e.getMessage()); + LOG.warn("Jupyter Notebook connection refused: " + e.getMessage()); } return false; } } catch (IOException e) { if (showNotification) { - LOG.warn("IPython Notebook connection refused: " + e.getMessage()); + LOG.warn("Jupyter Notebook connection refused: " + e.getMessage()); } return false; } @@ -269,7 +269,7 @@ public final class IpnbConnectionManager implements ProjectComponent { try { final PyPackage ipythonPackage = PyPackageManager.getInstance(sdk).findPackage("ipython", false); if (ipythonPackage == null) { - showWarning(fileEditor, "Add IPython to the interpreter of the current project.", null); + showWarning(fileEditor, "Add Jupyter to the interpreter of the current project.", null); return false; } } @@ -278,7 +278,7 @@ public final class IpnbConnectionManager implements ProjectComponent { final Pair hostPort = getHostPortFromUrl(url); if (hostPort == null) { - showWarning(fileEditor, "Please, check IPython Notebook URL in Settings->Tools->IPython Notebook", + showWarning(fileEditor, "Please, check Jupyter Notebook URL in Settings->Tools->Jupyter Notebook", new IpnbSettingsAdapter()); return false; } @@ -287,14 +287,23 @@ public final class IpnbConnectionManager implements ProjectComponent { showWarning(fileEditor, "Python Sdk is invalid, please check Python Interpreter in Settings->Python Interpreter", null); return false; } - String ipython = findIPythonRunner(homePath); Map env = null; + final ArrayList parameters = Lists.newArrayList(homePath); + String ipython = findJupyterRunner(homePath); if (ipython == null) { - ipython = PythonHelper.LOAD_ENTRY_POINT.asParamString(); - env = ImmutableMap.of("PYCHARM_EP_DIST", "ipython", "PYCHARM_EP_NAME", "ipython"); + ipython = findIPythonRunner(homePath); + if (ipython == null) { + ipython = PythonHelper.LOAD_ENTRY_POINT.asParamString(); + env = ImmutableMap.of("PYCHARM_EP_DIST", "ipython", "PYCHARM_EP_NAME", "ipython"); + } + parameters.add(ipython); + parameters.add("notebook"); } + else { + parameters.add(ipython); + } + parameters.add("--no-browser"); - final ArrayList parameters = Lists.newArrayList(homePath, ipython, "notebook", "--no-browser"); if (hostPort.getFirst() != null) { parameters.add("--ip"); parameters.add(hostPort.getFirst()); @@ -336,7 +345,7 @@ public final class IpnbConnectionManager implements ProjectComponent { @Override public void run() { new RunContentExecutor(myProject, processHandler) - .withTitle("IPython Notebook") + .withTitle("Jupyter Notebook") .withStop(new Runnable() { @Override public void run() { @@ -372,7 +381,8 @@ public final class IpnbConnectionManager implements ProjectComponent { } @Nullable - private static String findIPythonRunner(String homePath) { + @Deprecated + private static String findIPythonRunner(@NotNull final String homePath) { for (String name : Lists.newArrayList("ipython", "ipython-script.py")) { String runnerPath = PythonSdkType.getExecutablePath(homePath, name); if (runnerPath != null) { @@ -383,6 +393,18 @@ public final class IpnbConnectionManager implements ProjectComponent { return null; } + @Nullable + private static String findJupyterRunner(@NotNull final String homePath) { + for (String name : Lists.newArrayList("jupyter-notebook", "jupyter")) { + String runnerPath = PythonSdkType.getExecutablePath(homePath, name); + if (runnerPath != null) { + return runnerPath; + } + } + + return null; + } + @Nullable public static Pair getHostPortFromUrl(@NotNull String url) { try { @@ -435,7 +457,7 @@ public final class IpnbConnectionManager implements ProjectComponent { class IpnbSettingsAdapter extends HyperlinkAdapter { @Override protected void hyperlinkActivated(HyperlinkEvent e) { - ShowSettingsUtil.getInstance().showSettingsDialog(myProject, "IPython Notebook"); + ShowSettingsUtil.getInstance().showSettingsDialog(myProject, "Jupyter Notebook"); } } } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/actions/IpnbCreateFileAction.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/actions/IpnbCreateFileAction.java index 189ee133571d..a5b2be20174f 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/actions/IpnbCreateFileAction.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/actions/IpnbCreateFileAction.java @@ -24,18 +24,18 @@ import org.jetbrains.plugins.ipnb.IpnbFileType; public class IpnbCreateFileAction extends CreateFileFromTemplateAction implements DumbAware { public IpnbCreateFileAction() { - super("IPython Notebook", "Creates an IPython Notebook file from the specified template", IpnbFileType.INSTANCE.getIcon()); + super("Jupyter Notebook", "Creates an Jupyter Notebook file from the specified template", IpnbFileType.INSTANCE.getIcon()); } @Override protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) { builder - .setTitle("New IPython Notebook") - .addKind("IPython Notebook", IpnbFileType.INSTANCE.getIcon(), "IPython Notebook"); + .setTitle("New Jupyter Notebook") + .addKind("Jupyter Notebook", IpnbFileType.INSTANCE.getIcon(), "Jupyter Notebook"); } @Override protected String getActionName(PsiDirectory directory, String newName, String templateName) { - return "Create IPython Notebook " + newName; + return "Create Jupyter Notebook " + newName; } } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java index 4b9c569eb4c5..e9bc33718e75 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java @@ -81,7 +81,8 @@ public class IpnbParser { if (sdk != null) { try { final PyPackage ipython = PyPackageManager.getInstance(sdk).findPackage("ipython", true); - if (ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) { + final PyPackage jupyter = PyPackageManager.getInstance(sdk).findPackage("jupyter", true); + if (jupyter == null && ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) { return false; } }