mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Respect working directory setting in Python Console (PY-21373)
This commit is contained in:
@@ -142,7 +142,8 @@ public interface PydevConsoleRunner {
|
||||
return Pair.create(sdk, module);
|
||||
}
|
||||
|
||||
static String constructPythonPathCommand(Collection<String> pythonPath, String command) {
|
||||
static String constructPyPathAndWorkingDirCommand(Collection<String> pythonPath, String workingDir, String command) {
|
||||
pythonPath.add(workingDir);
|
||||
final String path = Joiner.on(", ").join(Collections2.transform(pythonPath, new Function<String, String>() {
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
@@ -150,7 +151,7 @@ public interface PydevConsoleRunner {
|
||||
}
|
||||
}));
|
||||
|
||||
return command.replace(PydevConsoleRunnerImpl.WORKING_DIR_ENV, path);
|
||||
return command.replace(PydevConsoleRunnerImpl.WORKING_DIR_AND_PY_PATHS_ENV, path);
|
||||
}
|
||||
|
||||
static Map<String, String> addDefaultEnvironments(Sdk sdk, Map<String, String> envs, @NotNull Project project) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.application.TransactionId;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -72,8 +70,6 @@ public class PydevConsoleRunnerFactory extends PythonConsoleRunnerFactory {
|
||||
customStartScript = "\n" + customStartScript;
|
||||
}
|
||||
|
||||
String selfPathAppend = PydevConsoleRunner.constructPythonPathCommand(pythonPath, customStartScript);
|
||||
|
||||
String workingDir = settingsProvider.getWorkingDirectory();
|
||||
if (StringUtil.isEmpty(workingDir)) {
|
||||
if (module != null && ModuleRootManager.getInstance(module).getContentRoots().length > 0) {
|
||||
@@ -93,6 +89,8 @@ public class PydevConsoleRunnerFactory extends PythonConsoleRunnerFactory {
|
||||
workingDir = pathMapper.convertToRemote(workingDir);
|
||||
}
|
||||
|
||||
String selfPathAppend = PydevConsoleRunner.constructPyPathAndWorkingDirCommand(pythonPath, workingDir, customStartScript);
|
||||
|
||||
BuildoutFacet facet = null;
|
||||
if (module != null) {
|
||||
facet = BuildoutFacet.getInstance(module);
|
||||
|
||||
@@ -127,9 +127,9 @@ import static com.intellij.execution.runners.AbstractConsoleRunnerWithHistory.re
|
||||
* @author traff, oleg
|
||||
*/
|
||||
public class PydevConsoleRunnerImpl implements PydevConsoleRunner {
|
||||
public static final String WORKING_DIR_ENV = "WORKING_DIR_AND_PYTHON_PATHS";
|
||||
public static final String WORKING_DIR_AND_PY_PATHS_ENV = "WORKING_DIR_AND_PYTHON_PATHS";
|
||||
public static final String CONSOLE_START_COMMAND = "import sys; print('Python %s on %s' % (sys.version, sys.platform))\n" +
|
||||
"sys.path.extend([" + WORKING_DIR_ENV + "])\n";
|
||||
"sys.path.extend([" + WORKING_DIR_AND_PY_PATHS_ENV + "])\n";
|
||||
private static final Logger LOG = Logger.getInstance(PydevConsoleRunnerImpl.class.getName());
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public static final String PYDEV_PYDEVCONSOLE_PY = "pydev/pydevconsole.py";
|
||||
|
||||
Reference in New Issue
Block a user