Add possibility for flavor to patch command line before execution (https://github...
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 12 Apr 2017 12:42:38 +0000 (14:42 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 12 Apr 2017 12:47:02 +0000 (14:47 +0200)
python/src/com/jetbrains/python/sdk/PySdkUtil.java
python/src/com/jetbrains/python/sdk/PythonEnvUtil.java
python/src/com/jetbrains/python/sdk/flavors/PythonSdkFlavor.java

index 48210bbd82e7634d58591b523f406d51ecb36359..1a38fd9b7c10064972f9975acc47f6dc9ec6d30a 100644 (file)
@@ -33,6 +33,8 @@ import com.intellij.psi.PsiFile;
 import com.intellij.remote.RemoteSdkAdditionalData;
 import com.intellij.util.SystemProperties;
 import com.intellij.util.containers.HashMap;
+import com.jetbrains.python.run.CommandLinePatcher;
+import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -125,6 +127,14 @@ public class PySdkUtil {
     try {
 
       final GeneralCommandLine commandLine = cmd.withWorkDirectory(homePath).withEnvironment(env);
+
+      final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(commandLine.getExePath());
+
+      final CommandLinePatcher cmdLinePatcher = flavor.commandLinePatcher();
+      if (cmdLinePatcher != null) {
+        cmdLinePatcher.patchCommandLine(cmd);
+      }
+
       final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine);
       if (stdin != null) {
         final OutputStream processInput = processHandler.getProcessInput();
index 03fed89449b5b9df388d027de1f5cd811f400202..48ab5234ff15a40a6bd6f7179667f1bb138f3b25 100644 (file)
@@ -66,6 +66,7 @@ public class PythonEnvUtil {
    * @param value  what to append
    * @return modified path-like string
    */
+
   @NotNull
   public static String appendToPathEnvVar(@Nullable String source, @NotNull String value) {
     if (StringUtil.isEmpty(source)) return value;
index 59de303a73fbf38204ebfda5a2fa5e384320c75f..5181beb33af4633dda753095a4487e279921c2e5 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.PatternUtil;
 import com.jetbrains.python.psi.LanguageLevel;
+import com.jetbrains.python.run.CommandLinePatcher;
 import com.jetbrains.python.sdk.PySdkUtil;
 import com.jetbrains.python.sdk.PythonEnvUtil;
 import com.jetbrains.python.sdk.PythonSdkAdditionalData;
@@ -256,4 +257,9 @@ public abstract class PythonSdkFlavor {
   public VirtualFile getSdkPath(VirtualFile path) {
     return path;
   }
+
+  @Nullable
+  public CommandLinePatcher commandLinePatcher() {
+    return null;
+  }
 }