PY-80682 Jupyter: Error and statistic is not collected

Signed-off-by: Nikita.Ashihmin <nikita.ashihmin@jetbrains.com>
(cherry picked from commit 4a43912a20772043c08ec14e6fc39282ea3629da)

GitOrigin-RevId: 2fb4433a615514b1048ec9bbb14b5bf0885934fe
This commit is contained in:
Nikita.Ashihmin
2025-04-26 15:01:47 +04:00
committed by intellij-monorepo-bot
parent 82eaf6e1ee
commit 83839169cd

View File

@@ -113,21 +113,26 @@ object PyPackageInstallUtils {
versionSpec: String? = null,
options: List<String> = emptyList(),
): Result<List<PythonPackage>> {
val pythonPackageManager = runCatching {
PythonPackageManager.forSdk(project, sdk)
}.getOrElse {
return Result.failure(it)
}
return try {
val pythonPackageManager = runCatching {
PythonPackageManager.forSdk(project, sdk)
}.getOrElse {
return Result.failure(it)
}
val spec = withContext(Dispatchers.IO) {
pythonPackageManager.repositoryManager.createSpecification(packageName, versionSpec)
} ?: return Result.failure(Exception("Package $packageName not found in any repository"))
val spec = withContext(Dispatchers.IO) {
pythonPackageManager.repositoryManager.createSpecification(packageName, versionSpec)
} ?: return Result.failure(Exception("Package $packageName not found in any repository"))
return if (withBackgroundProgress) {
pythonPackageManager.installPackage(spec, options, withBackgroundProgress = true)
return if (withBackgroundProgress) {
pythonPackageManager.installPackage(spec, options, withBackgroundProgress = true)
}
else {
pythonPackageManager.installPackage(spec, options, withBackgroundProgress)
}
}
else {
pythonPackageManager.installPackage(spec, options, withBackgroundProgress)
catch (t: Throwable) {
Result.failure(t)
}
}