From 139529ac2d2dd62393f8eef42a7e6c83c3cf7cf4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 19 Feb 2010 15:45:29 +0300 Subject: [PATCH] http://ea.jetbrains.com/browser/ea_problems/18809 --- .../python/run/AbstractPythonRunConfiguration.java | 2 ++ .../jetbrains/python/run/PythonCommandLineState.java | 10 +++++++--- .../python/testing/PythonTestCommandLineStateBase.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java b/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java index b9f1142533b2..e4eb48d6ade9 100644 --- a/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java +++ b/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java @@ -94,10 +94,12 @@ public abstract class AbstractPythonRunConfiguration extends ModuleBasedConfigur return sdkHome; } + @Nullable public String getInterpreterPath() { String sdkHome; if (myUseModuleSdk) { Sdk sdk = PythonSdkType.findPythonSdk(getModule()); + if (sdk == null) return null; sdkHome = sdk.getHomePath(); } else { diff --git a/python/src/com/jetbrains/python/run/PythonCommandLineState.java b/python/src/com/jetbrains/python/run/PythonCommandLineState.java index 65997678a159..8ba67703836e 100644 --- a/python/src/com/jetbrains/python/run/PythonCommandLineState.java +++ b/python/src/com/jetbrains/python/run/PythonCommandLineState.java @@ -84,7 +84,7 @@ public abstract class PythonCommandLineState extends CommandLineState { return processHandler; } - protected GeneralCommandLine generateCommandLine() { + protected GeneralCommandLine generateCommandLine() throws ExecutionException { GeneralCommandLine commandLine = new GeneralCommandLine(); setRunnerPath(commandLine); @@ -96,8 +96,12 @@ public abstract class PythonCommandLineState extends CommandLineState { return commandLine; } - protected void setRunnerPath(GeneralCommandLine commandLine) { - commandLine.setExePath(myConfig.getInterpreterPath()); + protected void setRunnerPath(GeneralCommandLine commandLine) throws ExecutionException { + String interpreterPath = myConfig.getInterpreterPath(); + if (interpreterPath == null) { + throw new ExecutionException("Cannot find Python interpreter for this run configuration"); + } + commandLine.setExePath(interpreterPath); } protected void buildCommandLineParameters(GeneralCommandLine commandLine) { diff --git a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java index bfbb5a834082..6c1bf40dbdcb 100644 --- a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java +++ b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java @@ -47,7 +47,7 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt return consoleView; } - protected GeneralCommandLine generateCommandLine() { + protected GeneralCommandLine generateCommandLine() throws ExecutionException { GeneralCommandLine cmd = new GeneralCommandLine(); setRunnerPath(cmd);