mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Restored "Install packaging tools" fix when there is no 'setuptools' installed
This commit is contained in:
@@ -35,7 +35,7 @@ def error(message, retcode):
|
||||
def error_no_pip():
|
||||
tb = sys.exc_traceback
|
||||
if tb is not None and tb.tb_next is None:
|
||||
error("Python package management tool 'pip' not found", ERROR_NO_PIP)
|
||||
error("Python packaging tool 'pip' not found", ERROR_NO_PIP)
|
||||
else:
|
||||
error(traceback.format_exc(), ERROR_EXCEPTION)
|
||||
|
||||
@@ -44,7 +44,7 @@ def do_list():
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
error("Python package management tool 'setuptools' or 'distribute' not found", ERROR_NO_SETUPTOOLS)
|
||||
error("Python packaging tool 'setuptools' not found", ERROR_NO_SETUPTOOLS)
|
||||
for pkg in pkg_resources.working_set:
|
||||
requires = ':'.join([str(x) for x in pkg.requires()])
|
||||
sys.stdout.write('\t'.join([pkg.project_name, pkg.version, pkg.location, requires])+chr(10))
|
||||
|
||||
@@ -30,20 +30,22 @@ import java.util.regex.Pattern;
|
||||
public class PyExecutionException extends ExecutionException {
|
||||
private static final Pattern WITH_CR_DELIMITER_PATTERN = Pattern.compile("(?<=\r|\n|\r\n)");
|
||||
|
||||
@NotNull private String myName;
|
||||
@NotNull private String myCommand;
|
||||
@NotNull private List<String> myArgs;
|
||||
private final int myReturnCode;
|
||||
@NotNull private String myMessage;
|
||||
@NotNull private final List<? extends PyExecutionFix> myFixes;
|
||||
|
||||
public PyExecutionException(@NotNull String name, @NotNull List<String> args, @NotNull String message) {
|
||||
this(name, args, message, Collections.<PyExecutionFix>emptyList());
|
||||
public PyExecutionException(@NotNull String message, @NotNull String command, @NotNull List<String> args, int returnCode) {
|
||||
this(message, command, args, returnCode, Collections.<PyExecutionFix>emptyList());
|
||||
}
|
||||
|
||||
public PyExecutionException(@NotNull String name, @NotNull List<String> args, @NotNull String message,
|
||||
@NotNull List<? extends PyExecutionFix> fixes) {
|
||||
super(String.format("External process error '%s %s':\n%s", name, StringUtil.join(args, " "), message));
|
||||
myName = name;
|
||||
public PyExecutionException(@NotNull String message, @NotNull String command, @NotNull List<String> args,
|
||||
int returnCode, @NotNull List<? extends PyExecutionFix> fixes) {
|
||||
super(message);
|
||||
myCommand = command;
|
||||
myArgs = args;
|
||||
myReturnCode = returnCode;
|
||||
myMessage = stripLinesWithoutLineFeeds(message);
|
||||
myFixes = fixes;
|
||||
}
|
||||
@@ -52,7 +54,7 @@ public class PyExecutionException extends ExecutionException {
|
||||
public String toString() {
|
||||
final StringBuilder b = new StringBuilder();
|
||||
b.append("The following command was executed:\n\n");
|
||||
final String command = getName() + " " + StringUtil.join(getArgs(), " ");
|
||||
final String command = getCommand() + " " + StringUtil.join(getArgs(), " ");
|
||||
b.append(command);
|
||||
b.append("\n\n");
|
||||
b.append("The error output of the command:\n\n");
|
||||
@@ -61,8 +63,8 @@ public class PyExecutionException extends ExecutionException {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return myName;
|
||||
public String getCommand() {
|
||||
return myCommand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -91,4 +93,8 @@ public class PyExecutionException extends ExecutionException {
|
||||
public List<? extends PyExecutionFix> getFixes() {
|
||||
return myFixes;
|
||||
}
|
||||
|
||||
public int getReturnCode() {
|
||||
return myReturnCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
@Override
|
||||
public void installManagement() throws ExecutionException {
|
||||
final boolean pre26 = PythonSdkType.getLanguageLevelForSdk(mySdk).isOlderThan(LanguageLevel.PYTHON26);
|
||||
if (!hasPackage(SETUPTOOLS, false) && !hasPackage(DISTRIBUTE, false)) {
|
||||
if (!hasSetuptools(false)) {
|
||||
final String name = SETUPTOOLS + "-" + (pre26 ? SETUPTOOLS_PRE_26_VERSION : SETUPTOOLS_VERSION);
|
||||
installManagement(name);
|
||||
}
|
||||
@@ -132,8 +132,19 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
|
||||
@Override
|
||||
public boolean hasManagement(boolean cachedOnly) throws ExecutionException {
|
||||
return (hasPackage(SETUPTOOLS, cachedOnly) || hasPackage(DISTRIBUTE, cachedOnly)) &&
|
||||
hasPackage(PIP, cachedOnly);
|
||||
return hasSetuptools(cachedOnly) && hasPackage(PIP, cachedOnly);
|
||||
}
|
||||
|
||||
private boolean hasSetuptools(boolean cachedOnly) throws ExecutionException {
|
||||
try {
|
||||
return hasPackage(SETUPTOOLS, cachedOnly) || hasPackage(DISTRIBUTE, cachedOnly);
|
||||
}
|
||||
catch (PyExecutionException e) {
|
||||
if (e.getReturnCode() == ERROR_NO_SETUPTOOLS) {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected void installManagement(@NotNull String name) throws ExecutionException {
|
||||
@@ -419,11 +430,11 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
final ProcessOutput output = getPythonProcessOutput(path, args, askForSudo, showProgress, workingDir);
|
||||
final int exitCode = output.getExitCode();
|
||||
if (output.isTimeout()) {
|
||||
throw new PyExecutionException(path, args, "Timed out");
|
||||
throw new PyExecutionException("Timed out", path, args, exitCode);
|
||||
}
|
||||
else if (exitCode != 0) {
|
||||
final String message = output.getStderr() + "\n" + output.getStdout();
|
||||
throw new PyExecutionException(path, args, message);
|
||||
throw new PyExecutionException(message, path, args, exitCode);
|
||||
}
|
||||
return output.getStdout();
|
||||
}
|
||||
@@ -494,7 +505,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
if (StringUtil.isEmptyOrSpaces(message)) {
|
||||
message = "Failed to perform action. Permission denied.";
|
||||
}
|
||||
throw new PyExecutionException(helperPath, args, message);
|
||||
throw new PyExecutionException(message, helperPath, args, result.getExitCode());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -505,10 +516,10 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
throw e;
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
throw new PyExecutionException(helperPath, args, e.getMessage());
|
||||
throw new PyExecutionException(e.getMessage(), helperPath, args, 0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new PyExecutionException(helperPath, args, e.getMessage());
|
||||
throw new PyExecutionException(e.getMessage(), helperPath, args, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,7 +530,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
for (String line : lines) {
|
||||
final List<String> fields = StringUtil.split(line, "\t");
|
||||
if (fields.size() < 3) {
|
||||
throw new PyExecutionException(PACKAGING_TOOL, Collections.<String>emptyList(), "Invalid output format");
|
||||
throw new PyExecutionException("Invalid output format", PACKAGING_TOOL, Collections.<String>emptyList(), 0);
|
||||
}
|
||||
final String name = fields.get(0);
|
||||
final String version = fields.get(1);
|
||||
|
||||
@@ -130,16 +130,15 @@ public class PyRemotePackageManagerImpl extends PyPackageManagerImpl {
|
||||
return processOutput;
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
throw new PyExecutionException(helperPath, args, "Error running SDK: " + e.getMessage());
|
||||
throw new PyExecutionException("Error running SDK: " + e.getMessage(), helperPath, args, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new PyExecutionException(helperPath, args,
|
||||
PythonRemoteInterpreterManager.WEB_DEPLOYMENT_PLUGIN_IS_DISABLED);
|
||||
throw new PyExecutionException(PythonRemoteInterpreterManager.WEB_DEPLOYMENT_PLUGIN_IS_DISABLED, helperPath, args, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new PyExecutionException(helperPath, args, "Invalid remote SDK");
|
||||
throw new PyExecutionException("Invalid remote SDK", helperPath, args, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +146,7 @@ public class PyRemotePackageManagerImpl extends PyPackageManagerImpl {
|
||||
final Throwable cause = exception.getCause();
|
||||
if (cause instanceof VagrantNotStartedException) {
|
||||
final String vagrantFolder = ((VagrantNotStartedException)cause).getVagrantFolder();
|
||||
return new PyExecutionException(command, args, "Vagrant instance is down", ImmutableList.of(new LaunchVagrantFix(vagrantFolder)));
|
||||
return new PyExecutionException("Vagrant instance is down", command, args, 0, ImmutableList.of(new LaunchVagrantFix(vagrantFolder)));
|
||||
}
|
||||
return exception;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel {
|
||||
try {
|
||||
myHasManagement = PyPackageManager.getInstance(selectedSdk).hasManagement(false);
|
||||
if (!myHasManagement) {
|
||||
throw new PyExecutionException("pip", Collections.<String>emptyList(), "Python packaging tools not found",
|
||||
throw new PyExecutionException("Python packaging tools not found", "pip", Collections.<String>emptyList(), 0,
|
||||
ImmutableList.of(new PyInstallPackageManagementFix()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user