mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
PY-82191 PySDK: Refactor new priject creation to support progress
GitOrigin-RevId: 6af82359528b086811c958577f296669eb578353
This commit is contained in:
committed by
intellij-monorepo-bot
parent
407ab341ba
commit
7a7c9b3f2d
@@ -1,12 +1,15 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.python.community.execService
|
||||
|
||||
import com.intellij.execution.process.AnsiEscapeDecoder
|
||||
import com.intellij.execution.process.ProcessOutputTypes
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.platform.eel.EelApi
|
||||
import com.intellij.platform.eel.getShell
|
||||
import com.intellij.platform.eel.provider.asNioPath
|
||||
import com.intellij.platform.eel.provider.utils.EelProcessExecutionResult
|
||||
import com.intellij.platform.eel.provider.utils.stdoutString
|
||||
import com.intellij.platform.util.progress.reportRawProgress
|
||||
import com.intellij.python.community.execService.impl.ExecServiceImpl
|
||||
import com.intellij.python.community.execService.impl.PyExecBundle
|
||||
import com.intellij.python.community.execService.impl.transformerToHandler
|
||||
@@ -91,7 +94,29 @@ suspend fun <T> ExecService.execute(
|
||||
options: ExecOptions = ExecOptions(),
|
||||
procListener: PyProcessListener? = null,
|
||||
processOutputTransformer: ProcessOutputTransformer<T>,
|
||||
): PyExecResult<T> = executeAdvanced(binary, { addArgs(*args.toTypedArray()) }, options, transformerToHandler(procListener, processOutputTransformer))
|
||||
): PyExecResult<T> {
|
||||
return reportRawProgress { reporter ->
|
||||
val ansiDecoder = AnsiEscapeDecoder()
|
||||
val listener = procListener ?: PyProcessListener {
|
||||
when (it) {
|
||||
is ProcessEvent.ProcessStarted, is ProcessEvent.ProcessEnded -> Unit
|
||||
is ProcessEvent.ProcessOutput -> {
|
||||
val outType = when (it.stream) {
|
||||
ProcessEvent.OutputType.STDOUT -> ProcessOutputTypes.STDOUT
|
||||
ProcessEvent.OutputType.STDERR -> ProcessOutputTypes.STDERR
|
||||
}
|
||||
ansiDecoder.escapeText(it.line, outType) { text, _ ->
|
||||
@Suppress("HardCodedStringLiteral")
|
||||
reporter.text(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
executeAdvanced(binary, { addArgs(*args.toTypedArray()) }, options, transformerToHandler(procListener
|
||||
?: listener, processOutputTransformer))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -115,5 +140,5 @@ data class ExecOptions(
|
||||
val env: Map<String, String> = emptyMap(),
|
||||
val workingDirectory: Path? = null,
|
||||
val processDescription: @Nls String? = null,
|
||||
val timeout: Duration = 1.minutes,
|
||||
val timeout: Duration = 5.minutes,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user