From 1339924c8bf5c1fd0130ac14b8d46ff6324f37d7 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 20 Aug 2015 14:31:19 +0200 Subject: [PATCH] Search for runner script. --- .../configuration/IpnbConnectionManager.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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 d0915370e40d..57bdb1e09fbd 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java @@ -22,7 +22,6 @@ import com.intellij.openapi.ui.popup.BalloonBuilder; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.HyperlinkAdapter; @@ -272,8 +271,11 @@ public final class IpnbConnectionManager implements ProjectComponent { return false; } final String homePath = sdk.getHomePath(); - if (homePath == null) return false; - final String ipython = PythonSdkType.getExecutablePath(homePath, SystemInfo.isWindows ? "ipython-script.py" : "ipython"); + if (homePath == null) { + showWarning(fileEditor, "Python Sdk is invalid, please check Python Interpreter in Settings->Python Interpreter", null); + return false; + } + final String ipython = findIPythonRunner(homePath); if (ipython == null) { showWarning(fileEditor, "IPython executable is not found, please check your IPython installation", null); return false; @@ -336,6 +338,18 @@ public final class IpnbConnectionManager implements ProjectComponent { } } + @Nullable + private static String findIPythonRunner(String homePath) { + for (String name : Lists.newArrayList("ipython", "ipython-script.py")) { + String runnerPath = PythonSdkType.getExecutablePath(homePath, name); + if (runnerPath != null) { + return runnerPath; + } + } + + return null; + } + @Nullable public static Pair getHostPortFromUrl(@NotNull String url) { try {