diff --git a/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java b/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java index 82c566fd1249..770fb7037c56 100644 --- a/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java +++ b/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.packaging; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.module.Module; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.Key; @@ -40,20 +41,20 @@ public abstract class PyPackageManager { return PyPackageManagers.getInstance().forSdk(sdk); } - public abstract void installManagement() throws PyExternalProcessException; + public abstract void installManagement() throws ExecutionException; public abstract boolean hasManagement(boolean cachedOnly); - public abstract void install(@NotNull String requirementString) throws PyExternalProcessException; - public abstract void install(@NotNull List requirements, @NotNull List extraArgs) throws PyExternalProcessException; - public abstract void uninstall(@NotNull List packages) throws PyExternalProcessException; + public abstract void install(@NotNull String requirementString) throws ExecutionException; + public abstract void install(@NotNull List requirements, @NotNull List extraArgs) throws ExecutionException; + public abstract void uninstall(@NotNull List packages) throws ExecutionException; public abstract void refresh(); @NotNull - public abstract String createVirtualEnv(@NotNull String destinationDir, boolean useGlobalSite) throws PyExternalProcessException; + public abstract String createVirtualEnv(@NotNull String destinationDir, boolean useGlobalSite) throws ExecutionException; @Nullable - public abstract List getPackages(boolean cachedOnly) throws PyExternalProcessException; + public abstract List getPackages(boolean cachedOnly) throws ExecutionException; @Nullable - public abstract PyPackage findPackage(@NotNull String name, boolean cachedOnly) throws PyExternalProcessException; + public abstract PyPackage findPackage(@NotNull String name, boolean cachedOnly) throws ExecutionException; @Nullable public abstract List getRequirements(@NotNull Module module); @Nullable - public abstract Set getDependents(@NotNull PyPackage pkg) throws PyExternalProcessException; + public abstract Set getDependents(@NotNull PyPackage pkg) throws ExecutionException; } diff --git a/python/openapi/src/com/jetbrains/python/packaging/PyProcessCancelledException.java b/python/openapi/src/com/jetbrains/python/packaging/PyProcessCancelledException.java deleted file mode 100644 index 9721bec0bb86..000000000000 --- a/python/openapi/src/com/jetbrains/python/packaging/PyProcessCancelledException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.python.packaging; - -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author vlan - */ -public class PyProcessCancelledException extends PyExternalProcessException { - public PyProcessCancelledException(@NotNull String name, @NotNull List args) { - super(255, name, args, "Process cancelled"); - } -} diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/PyTemplatesUtil.java b/python/openapi/src/com/jetbrains/python/templateLanguages/PyTemplatesUtil.java index c37c65ed4144..a770220886e0 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/PyTemplatesUtil.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/PyTemplatesUtil.java @@ -15,9 +15,9 @@ */ package com.jetbrains.python.templateLanguages; +import com.intellij.execution.ExecutionException; import com.intellij.facet.ui.ValidationResult; import com.intellij.openapi.projectRoots.Sdk; -import com.jetbrains.python.packaging.PyExternalProcessException; import com.jetbrains.python.packaging.PyPackage; import com.jetbrains.python.packaging.PyPackageManager; import org.jetbrains.annotations.NonNls; @@ -44,7 +44,7 @@ public class PyTemplatesUtil { if (installedPackage == null) return new ValidationResult(templateBinding + " will be installed on selected interpreter"); } - catch (PyExternalProcessException ignored) { + catch (ExecutionException ignored) { } } } @@ -55,7 +55,7 @@ public class PyTemplatesUtil { return new ValidationResult(language + " will be installed on selected interpreter"); } } - catch (PyExternalProcessException ignored) { + catch (ExecutionException ignored) { } } return null; diff --git a/python/python-rest/src/com/jetbrains/rest/RestPythonUtil.java b/python/python-rest/src/com/jetbrains/rest/RestPythonUtil.java index e6d379f03676..f7468d82a426 100644 --- a/python/python-rest/src/com/jetbrains/rest/RestPythonUtil.java +++ b/python/python-rest/src/com/jetbrains/rest/RestPythonUtil.java @@ -15,6 +15,7 @@ */ package com.jetbrains.rest; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.LangDataKeys; @@ -23,7 +24,6 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; -import com.jetbrains.python.packaging.PyExternalProcessException; import com.jetbrains.python.packaging.PyPackage; import com.jetbrains.python.packaging.PyPackageManager; import com.jetbrains.python.sdk.PythonSdkType; @@ -52,7 +52,7 @@ public class RestPythonUtil { final PyPackage sphinx = manager.findPackage("Sphinx", false); presentation.setEnabled(sphinx != null); } - catch (PyExternalProcessException ignored) { + catch (ExecutionException ignored) { } } } diff --git a/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java b/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java index e9585a5cd952..3a29f623dae4 100644 --- a/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java +++ b/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java @@ -17,6 +17,7 @@ package com.jetbrains.python.configuration; import com.google.common.collect.Lists; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.execution.ExecutionException; import com.intellij.facet.impl.ui.FacetErrorPanel; import com.intellij.facet.ui.FacetConfigurationQuickFix; import com.intellij.facet.ui.FacetEditorValidator; @@ -161,7 +162,7 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable, No public void started() {} @Override - public void finished(List exceptions) { + public void finished(List exceptions) { if (exceptions.isEmpty()) { VFSTestFrameworkListener.getInstance().testInstalled(true, sdk.getHomePath(), name); facetErrorPanel.getValidatorsManager().validate(); diff --git a/python/src/com/jetbrains/python/inspections/PyPackageRequirementsInspection.java b/python/src/com/jetbrains/python/inspections/PyPackageRequirementsInspection.java index 165a3ee04e2c..cc89d0b49444 100644 --- a/python/src/com/jetbrains/python/inspections/PyPackageRequirementsInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyPackageRequirementsInspection.java @@ -18,6 +18,7 @@ package com.jetbrains.python.inspections; import com.google.common.collect.ImmutableSet; import com.intellij.codeInspection.*; import com.intellij.codeInspection.ui.ListEditForm; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; @@ -212,7 +213,7 @@ public class PyPackageRequirementsInspection extends PyInspection { try { packages = PyPackageManager.getInstance(sdk).getPackages(PySdkUtil.isRemote(sdk)); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { return null; } if (packages == null) return null; @@ -248,7 +249,7 @@ public class PyPackageRequirementsInspection extends PyInspection { try { packages = manager.getPackages(PySdkUtil.isRemote(sdk)); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { return null; } if (packages == null) return null; @@ -330,7 +331,7 @@ public class PyPackageRequirementsInspection extends PyInspection { if (installManagement) { final PyPackageManagerUI ui = new PyPackageManagerUI(project, mySdk, new UIListener(myModule) { @Override - public void finished(List exceptions) { + public void finished(List exceptions) { super.finished(exceptions); if (exceptions.isEmpty()) { installRequirements(project, chosen); @@ -363,7 +364,7 @@ public class PyPackageRequirementsInspection extends PyInspection { } @Override - public void finished(List exceptions) { + public void finished(List exceptions) { setRunningPackagingTasks(myModule, false); } } diff --git a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java index 070a89fcb3fe..d2581fd4dec2 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java @@ -18,6 +18,7 @@ package com.jetbrains.python.packaging; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.intellij.execution.ExecutionException; +import com.intellij.execution.RunCanceledByUserException; import com.intellij.execution.process.*; import com.intellij.execution.util.ExecUtil; import com.intellij.openapi.application.Application; @@ -91,7 +92,7 @@ public class PyPackageManagerImpl extends PyPackageManager { private final Object myCacheLock = new Object(); private List myPackagesCache = null; - private PyExternalProcessException myExceptionCache = null; + private ExecutionException myExceptionCache = null; protected Sdk mySdk; @@ -117,7 +118,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } @Override - public void installManagement() throws PyExternalProcessException { + public void installManagement() throws ExecutionException { final boolean pre26 = PythonSdkType.getLanguageLevelForSdk(mySdk).isOlderThan(LanguageLevel.PYTHON26); if (!hasPackage(SETUPTOOLS, false) && !hasPackage(DISTRIBUTE, false)) { final String name = SETUPTOOLS + "-" + (pre26 ? SETUPTOOLS_PRE_26_VERSION : SETUPTOOLS_VERSION); @@ -135,7 +136,7 @@ public class PyPackageManagerImpl extends PyPackageManager { hasPackage(PIP, cachedOnly); } - protected void installManagement(@NotNull String name) throws PyExternalProcessException { + protected void installManagement(@NotNull String name) throws ExecutionException { final String dirName = extractHelper(name + ".tar.gz"); try { final String fileName = dirName + name + File.separatorChar + "setup.py"; @@ -148,7 +149,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } @NotNull - private String extractHelper(@NotNull String name) throws PyExternalProcessException { + private String extractHelper(@NotNull String name) throws ExecutionException { final String helperPath = getHelperPath(name); final ArrayList args = Lists.newArrayList(UNTAR, helperPath); final String result = getHelperResult(PACKAGING_TOOL, args, false, false, null); @@ -163,7 +164,7 @@ public class PyPackageManagerImpl extends PyPackageManager { try { return findPackage(name, cachedOnly) != null; } - catch (PyExternalProcessException ignored) { + catch (ExecutionException ignored) { return false; } } @@ -184,13 +185,13 @@ public class PyPackageManagerImpl extends PyPackageManager { } @Override - public void install(@NotNull String requirementString) throws PyExternalProcessException { + public void install(@NotNull String requirementString) throws ExecutionException { installManagement(); install(Collections.singletonList(PyRequirement.fromString(requirementString)), Collections.emptyList()); } @Override - public void install(@NotNull List requirements, @NotNull List extraArgs) throws PyExternalProcessException { + public void install(@NotNull List requirements, @NotNull List extraArgs) throws ExecutionException { final List args = new ArrayList(); args.add(INSTALL); final File buildDir; @@ -198,7 +199,7 @@ public class PyPackageManagerImpl extends PyPackageManager { buildDir = FileUtil.createTempDirectory("pycharm-packaging", null); } catch (IOException e) { - throw new PyExternalProcessException(ERROR_ACCESS_DENIED, PACKAGING_TOOL, args, "Cannot create temporary build directory"); + throw new ExecutionException("Cannot create temporary build directory"); } if (!extraArgs.contains(BUILD_DIR_OPTION)) { args.addAll(Arrays.asList(BUILD_DIR_OPTION, buildDir.getAbsolutePath())); @@ -224,7 +225,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } } - public void uninstall(@NotNull List packages) throws PyExternalProcessException { + public void uninstall(@NotNull List packages) throws ExecutionException { try { final List args = new ArrayList(); args.add(UNINSTALL); @@ -246,7 +247,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } @Nullable - public List getPackages(boolean cachedOnly) throws PyExternalProcessException { + public List getPackages(boolean cachedOnly) throws ExecutionException { synchronized (myCacheLock) { if (myPackagesCache != null) { return myPackagesCache; @@ -266,7 +267,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } return packages; } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { synchronized (myCacheLock) { myExceptionCache = e; } @@ -275,7 +276,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } @Nullable - public Set getDependents(@NotNull PyPackage pkg) throws PyExternalProcessException { + public Set getDependents(@NotNull PyPackage pkg) throws ExecutionException { final List packages = getPackages(false); if (packages != null) { final Set dependents = new HashSet(); @@ -294,7 +295,7 @@ public class PyPackageManagerImpl extends PyPackageManager { @Override @Nullable - public PyPackage findPackage(@NotNull String name, boolean cachedOnly) throws PyExternalProcessException { + public PyPackage findPackage(@NotNull String name, boolean cachedOnly) throws ExecutionException { final List packages = getPackages(cachedOnly); if (packages != null) { for (PyPackage pkg : packages) { @@ -307,7 +308,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } @NotNull - public String createVirtualEnv(@NotNull String destinationDir, boolean useGlobalSite) throws PyExternalProcessException { + public String createVirtualEnv(@NotNull String destinationDir, boolean useGlobalSite) throws ExecutionException { final List args = new ArrayList(); final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(mySdk); final boolean usePyVenv = languageLevel.isAtLeast(LanguageLevel.PYTHON33); @@ -404,10 +405,10 @@ public class PyPackageManagerImpl extends PyPackageManager { @NotNull private String getHelperResult(@NotNull String helper, @NotNull List args, boolean askForSudo, - boolean showProgress, @Nullable String parentDir) throws PyExternalProcessException { + boolean showProgress, @Nullable String parentDir) throws ExecutionException { final String helperPath = getHelperPath(helper); if (helperPath == null) { - throw new PyExternalProcessException(ERROR_TOOL_NOT_FOUND, helper, args, "Cannot find external tool"); + throw new ExecutionException("Cannot find external tool: " + helper); } return getPythonProcessResult(helperPath, args, askForSudo, showProgress, parentDir); } @@ -419,7 +420,7 @@ public class PyPackageManagerImpl extends PyPackageManager { @NotNull private String getPythonProcessResult(@NotNull String path, @NotNull List args, boolean askForSudo, - boolean showProgress, @Nullable String workingDir) throws PyExternalProcessException { + boolean showProgress, @Nullable String workingDir) throws ExecutionException { final ProcessOutput output = getPythonProcessOutput(path, args, askForSudo, showProgress, workingDir); final int exitCode = output.getExitCode(); if (output.isTimeout()) { @@ -434,10 +435,10 @@ public class PyPackageManagerImpl extends PyPackageManager { @NotNull protected ProcessOutput getPythonProcessOutput(@NotNull String helperPath, @NotNull List args, boolean askForSudo, - boolean showProgress, @Nullable String workingDir) throws PyExternalProcessException { + boolean showProgress, @Nullable String workingDir) throws ExecutionException { final String homePath = mySdk.getHomePath(); if (homePath == null) { - throw new PyExternalProcessException(ERROR_INVALID_SDK, helperPath, args, "Cannot find interpreter for SDK"); + throw new ExecutionException("Cannot find Python interpreter for SDK " + mySdk.getName()); } if (workingDir == null) { workingDir = new File(homePath).getParent(); @@ -487,7 +488,7 @@ public class PyPackageManagerImpl extends PyPackageManager { result = handler.runProcess(TIMEOUT); } if (result.isCancelled()) { - throw new PyProcessCancelledException(helperPath, args); + throw new RunCanceledByUserException(); } String message = result.getStderr(); if (result.getExitCode() != 0) { @@ -502,7 +503,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } return result; } - catch (PyProcessCancelledException e) { + catch (RunCanceledByUserException e) { throw e; } catch (ExecutionException e) { @@ -514,7 +515,7 @@ public class PyPackageManagerImpl extends PyPackageManager { } @NotNull - private static List parsePackagingToolOutput(@NotNull String s) throws PyExternalProcessException { + private static List parsePackagingToolOutput(@NotNull String s) throws ExecutionException { final String[] lines = StringUtil.splitByLines(s); final List packages = new ArrayList(); for (String line : lines) { diff --git a/python/src/com/jetbrains/python/packaging/PyPackageManagerUI.java b/python/src/com/jetbrains/python/packaging/PyPackageManagerUI.java index f504cbae33b9..1ddb2a9c1ae3 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageManagerUI.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageManagerUI.java @@ -15,6 +15,8 @@ */ package com.jetbrains.python.packaging; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.RunCanceledByUserException; import com.intellij.icons.AllIcons; import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; @@ -50,7 +52,7 @@ public class PyPackageManagerUI { public interface Listener { void started(); - void finished(List exceptions); + void finished(List exceptions); } public PyPackageManagerUI(@NotNull Project project, @NotNull Sdk sdk, @Nullable Listener listener) { @@ -113,14 +115,14 @@ public class PyPackageManagerUI { } if (warning[0] != Messages.YES) return true; } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { LOG.info("Error loading packages dependents: " + e.getMessage(), e); } return false; } - private static Map> collectDependents(@NotNull final List packages, Sdk sdk) - throws PyExternalProcessException { + private static Map> collectDependents(@NotNull final List packages, + Sdk sdk) throws ExecutionException { Map> dependentPackages = new HashMap>(); for (PyPackage pkg : packages) { final Set dependents = PyPackageManager.getInstance(sdk).getDependents(pkg); @@ -152,7 +154,7 @@ public class PyPackageManagerUI { } @NotNull - protected abstract List runTask(@NotNull ProgressIndicator indicator); + protected abstract List runTask(@NotNull ProgressIndicator indicator); @NotNull protected abstract String getSuccessTitle(); @@ -175,7 +177,7 @@ public class PyPackageManagerUI { } } - protected void taskFinished(@NotNull final List exceptions) { + protected void taskFinished(@NotNull final List exceptions) { final Ref notificationRef = new Ref(null); if (exceptions.isEmpty()) { notificationRef.set(new Notification(PACKAGING_GROUP_ID, getSuccessTitle(), getSuccessDescription(), @@ -211,9 +213,9 @@ public class PyPackageManagerUI { }); } - private static boolean isCancelled(@NotNull List exceptions) { - for (PyExternalProcessException e : exceptions) { - if (e instanceof PyProcessCancelledException) { + private static boolean isCancelled(@NotNull List exceptions) { + for (ExecutionException e : exceptions) { + if (e instanceof RunCanceledByUserException) { return true; } } @@ -239,8 +241,8 @@ public class PyPackageManagerUI { @NotNull @Override - protected List runTask(@NotNull ProgressIndicator indicator) { - final List exceptions = new ArrayList(); + protected List runTask(@NotNull ProgressIndicator indicator) { + final List exceptions = new ArrayList(); final int size = myRequirements.size(); final PyPackageManager manager = PyPackageManagers.getInstance().forSdk(mySdk); for (int i = 0; i < size; i++) { @@ -256,11 +258,11 @@ public class PyPackageManagerUI { try { manager.install(Arrays.asList(requirement), myExtraArgs); } - catch (PyProcessCancelledException e) { + catch (RunCanceledByUserException e) { exceptions.add(e); break; } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { exceptions.add(e); } } @@ -297,15 +299,15 @@ public class PyPackageManagerUI { @NotNull @Override - protected List runTask(@NotNull ProgressIndicator indicator) { - final List exceptions = new ArrayList(); + protected List runTask(@NotNull ProgressIndicator indicator) { + final List exceptions = new ArrayList(); final PyPackageManager manager = PyPackageManagers.getInstance().forSdk(mySdk); indicator.setText("Installing packaging tools..."); indicator.setIndeterminate(true); try { manager.installManagement(); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { exceptions.add(e); } manager.refresh(); @@ -334,14 +336,14 @@ public class PyPackageManagerUI { @NotNull @Override - protected List runTask(@NotNull ProgressIndicator indicator) { + protected List runTask(@NotNull ProgressIndicator indicator) { final PyPackageManager manager = PyPackageManagers.getInstance().forSdk(mySdk); indicator.setIndeterminate(true); try { manager.uninstall(myPackages); return Arrays.asList(); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { return Arrays.asList(e); } finally { @@ -374,11 +376,11 @@ public class PyPackageManagerUI { } } - public static String createDescription(List exceptions, String firstLine) { + public static String createDescription(List exceptions, String firstLine) { final StringBuilder b = new StringBuilder(); b.append(firstLine); b.append("\n\n"); - for (PyExternalProcessException exception : exceptions) { + for (ExecutionException exception : exceptions) { b.append(exception.toString()); b.append("\n"); } diff --git a/python/src/com/jetbrains/python/packaging/PyRemotePackageManagerImpl.java b/python/src/com/jetbrains/python/packaging/PyRemotePackageManagerImpl.java index bf199d6ded80..2a579f16d44d 100644 --- a/python/src/com/jetbrains/python/packaging/PyRemotePackageManagerImpl.java +++ b/python/src/com/jetbrains/python/packaging/PyRemotePackageManagerImpl.java @@ -78,10 +78,10 @@ public class PyRemotePackageManagerImpl extends PyPackageManagerImpl { protected ProcessOutput getPythonProcessOutput(@NotNull String helperPath, @NotNull List args, boolean askForSudo, - boolean showProgress, @Nullable String workingDir) throws PyExternalProcessException { + boolean showProgress, @Nullable String workingDir) throws ExecutionException { final String homePath = mySdk.getHomePath(); if (homePath == null) { - throw new PyExternalProcessException(ERROR_INVALID_SDK, helperPath, args, "Cannot find interpreter for SDK"); + throw new ExecutionException("Cannot find Python interpreter for SDK " + mySdk.getName()); } final SdkAdditionalData sdkData = mySdk.getSdkAdditionalData(); if (sdkData instanceof PyRemoteSdkAdditionalDataBase) { //remote interpreter @@ -167,7 +167,7 @@ public class PyRemotePackageManagerImpl extends PyPackageManagerImpl { } @Override - protected void installManagement(@NotNull String name) throws PyExternalProcessException { + protected void installManagement(@NotNull String name) throws ExecutionException { super.installManagement(name); // TODO: remove temp directory for remote interpreter } diff --git a/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java b/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java index 6bb976b6b910..e100d4444d1e 100644 --- a/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java +++ b/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java @@ -16,6 +16,7 @@ package com.jetbrains.python.packaging.ui; import com.google.common.collect.Sets; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -127,7 +128,7 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel { } @Override - public void finished(List exceptions) { + public void finished(List exceptions) { myPackagesTable.setPaintBusy(false); PyPackageManager packageManager = PyPackageManager.getInstance(sdk); if (!exceptions.isEmpty()) { diff --git a/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java b/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java index 802a5ab612f4..d3e23c594ed8 100644 --- a/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java +++ b/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.packaging.ui; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.text.StringUtil; @@ -142,7 +143,7 @@ public class PyPackageManagementService extends PackageManagementService { }); } } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { throw new IOException(e); } return packages != null ? new ArrayList(packages) : new ArrayList(); @@ -183,14 +184,14 @@ public class PyPackageManagementService extends PackageManagementService { } @Override - public void finished(@Nullable List exceptions) { + public void finished(@Nullable List exceptions) { listener.operationFinished(packageName, toErrorDescription(exceptions)); } }); ui.install(Collections.singletonList(req), extraArgs); } - private String toErrorDescription(List exceptions) { + private String toErrorDescription(List exceptions) { String errorDescription = null; if (exceptions != null && exceptions.size() > 0) { errorDescription = PyPackageManagerUI.createDescription(exceptions, ""); @@ -208,7 +209,7 @@ public class PyPackageManagementService extends PackageManagementService { } @Override - public void finished(final List exceptions) { + public void finished(final List exceptions) { listener.operationFinished(packageName, toErrorDescription(exceptions)); } }); diff --git a/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java b/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java index 1d0a4bc3ad54..ebb8813f08c9 100644 --- a/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java +++ b/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java @@ -17,6 +17,7 @@ package com.jetbrains.python.sdk; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; +import com.intellij.execution.ExecutionException; import com.intellij.facet.ui.FacetEditorValidator; import com.intellij.facet.ui.FacetValidatorsManager; import com.intellij.openapi.application.Application; @@ -49,7 +50,6 @@ import com.intellij.util.NullableConsumer; import com.intellij.util.PathUtil; import com.intellij.util.PlatformUtils; import com.intellij.webcore.packaging.PackagesNotificationPanel; -import com.jetbrains.python.packaging.PyExternalProcessException; import com.jetbrains.python.packaging.PyPackageManager; import com.jetbrains.python.packaging.PyPackageService; import com.jetbrains.python.sdk.flavors.VirtualEnvSdkFlavor; @@ -421,7 +421,7 @@ public class CreateVirtualEnvDialog extends IdeaDialog { indicator.setText("Creating virtual environment for " + basicSdk.getName()); myPath = packageManager.createVirtualEnv(getDestination(), useGlobalSitePackages()); } - catch (final PyExternalProcessException e) { + catch (final ExecutionException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { diff --git a/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java b/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java index b1e8ca19acf8..0ce96cf42ea6 100644 --- a/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java +++ b/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java @@ -42,7 +42,6 @@ import com.intellij.util.io.ZipUtil; import com.jetbrains.python.PyBundle; import com.jetbrains.python.PyNames; import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil; -import com.jetbrains.python.packaging.PyExternalProcessException; import com.jetbrains.python.packaging.PyPackageManager; import com.jetbrains.python.psi.resolve.PythonSdkPathCache; import com.jetbrains.python.remote.PythonRemoteInterpreterManager; @@ -351,7 +350,7 @@ public class PySkeletonRefresher { // Force loading packages PyPackageManager.getInstance(mySdk).getPackages(false); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { // ignore - already logged } } diff --git a/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java b/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java index 64adf2093028..c121dacdeaf8 100644 --- a/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java +++ b/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.testing; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.components.ServiceManager; @@ -33,7 +34,6 @@ import com.intellij.util.messages.MessageBus; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import com.jetbrains.python.PyNames; -import com.jetbrains.python.packaging.PyExternalProcessException; import com.jetbrains.python.packaging.PyPackageManager; import com.jetbrains.python.sdk.PySdkUtil; import com.jetbrains.python.sdk.PythonSdkType; @@ -134,7 +134,7 @@ public class VFSTestFrameworkListener implements ApplicationComponent { try { return packageManager.findPackage(testPackageName, false) != null; } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { LOG.info("Can't load package list " + e.getMessage()); } return null; diff --git a/python/src/com/jetbrains/python/testing/pytest/PyTestConfigurationProducer.java b/python/src/com/jetbrains/python/testing/pytest/PyTestConfigurationProducer.java index 8dc27d4fd995..575690c52dae 100644 --- a/python/src/com/jetbrains/python/testing/pytest/PyTestConfigurationProducer.java +++ b/python/src/com/jetbrains/python/testing/pytest/PyTestConfigurationProducer.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.testing.pytest; +import com.intellij.execution.ExecutionException; import com.intellij.execution.Location; import com.intellij.execution.actions.ConfigurationContext; import com.intellij.openapi.module.Module; @@ -28,7 +29,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFileSystemItem; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.webcore.packaging.PackageVersionComparator; -import com.jetbrains.python.packaging.PyExternalProcessException; import com.jetbrains.python.packaging.PyPackage; import com.jetbrains.python.packaging.PyPackageManager; import com.jetbrains.python.psi.PyClass; @@ -106,7 +106,7 @@ public class PyTestConfigurationProducer extends PythonTestConfigurationProducer keywords = pyClass.getName() + "." + keywords; } } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { keywords = pyClass.getName() + "." + keywords; } } diff --git a/python/testSrc/com/jetbrains/env/python/PyPackagingTest.java b/python/testSrc/com/jetbrains/env/python/PyPackagingTest.java index c4616e5e3add..c15d0dcb871d 100644 --- a/python/testSrc/com/jetbrains/env/python/PyPackagingTest.java +++ b/python/testSrc/com/jetbrains/env/python/PyPackagingTest.java @@ -1,6 +1,7 @@ package com.jetbrains.env.python; import com.google.common.collect.Sets; +import com.intellij.execution.ExecutionException; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; @@ -44,11 +45,7 @@ public class PyPackagingTest extends PyEnvTestCase { try { packages = PyPackageManager.getInstance(sdk).getPackages(false); } - catch (PyExternalProcessException e) { - final int retcode = e.getRetcode(); - if (retcode != PyPackageManagerImpl.ERROR_NO_PIP && retcode != PyPackageManagerImpl.ERROR_NO_SETUPTOOLS) { - fail(String.format("Error for interpreter '%s': %s", sdk.getHomePath(), e.getMessage())); - } + catch (ExecutionException ignored) { } if (packages != null) { assertTrue(packages.size() > 0); @@ -87,7 +84,7 @@ public class PyPackagingTest extends PyEnvTestCase { catch (IOException e) { throw new RuntimeException(e); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { throw new RuntimeException(String.format("Error for interpreter '%s': %s", sdk.getHomePath(), e.getMessage()), e); } } @@ -123,7 +120,7 @@ public class PyPackagingTest extends PyEnvTestCase { final PyPackage pip2 = findPackage("pip", packages3); assertNull(pip2); } - catch (PyExternalProcessException e) { + catch (ExecutionException e) { new RuntimeException(String.format("Error for interpreter '%s': %s", sdk.getHomePath(), e.getMessage()), e); } catch (IOException e) {