mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExecService clean-up, add eel-test.
`Command` was a mistake: we should use `Binary` but with the ability to resolve it. GitOrigin-RevId: 5151c6131af0338ea919d650c317cd9b88baeb12
This commit is contained in:
committed by
intellij-monorepo-bot
parent
920e58a168
commit
0d1edf1017
@@ -21,5 +21,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit5" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.eel" />
|
||||
<orderEntry type="module" module-name="intellij.platform.eel.provider" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -3,6 +3,7 @@ package com.jetbrains.python.errorProcessing
|
||||
|
||||
import com.intellij.execution.process.ProcessOutput
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import com.jetbrains.python.PyCommunityBundle
|
||||
import org.jetbrains.annotations.Nls
|
||||
|
||||
@@ -10,22 +11,19 @@ import org.jetbrains.annotations.Nls
|
||||
* External process error.
|
||||
*/
|
||||
class ExecError(
|
||||
val exe: EelPath,
|
||||
/**
|
||||
* I.e ['python', '-v']
|
||||
* I.e ['-v']
|
||||
*/
|
||||
val command: Array<String>,
|
||||
val args: Array<String>,
|
||||
|
||||
val errorReason: ExecErrorReason,
|
||||
/**
|
||||
* optional message to be displayed to the user: Why did we run this process. I.e "running pip to install package".
|
||||
*/
|
||||
val additionalMessageToUser: @NlsContexts.DialogTitle String? = null,
|
||||
) : PyError(getExecErrorMessage(command, additionalMessageToUser, errorReason)) {
|
||||
val exeAndArgs: Pair<String, Array<String>> = Pair(command[0], command.drop(1).toTypedArray())
|
||||
|
||||
init {
|
||||
assert(command.isNotEmpty()) { "Command can't be empty" }
|
||||
}
|
||||
) : PyError(getExecErrorMessage(exe.toString(), args, additionalMessageToUser, errorReason)) {
|
||||
val asCommand: String get() = (arrayOf(exe.toString()) + args).joinToString(" ")
|
||||
}
|
||||
|
||||
|
||||
@@ -51,12 +49,13 @@ sealed interface ExecErrorReason {
|
||||
fun ProcessOutput.asExecutionFailed(): ExecErrorReason.UnexpectedProcessTermination =
|
||||
ExecErrorReason.UnexpectedProcessTermination(exitCode, stdout, stderr)
|
||||
|
||||
internal fun getExecErrorMessage(
|
||||
command: Array<String>,
|
||||
private fun getExecErrorMessage(
|
||||
exec: String,
|
||||
args: Array<String>,
|
||||
additionalMessage: @NlsContexts.DialogTitle String?,
|
||||
execErrorReason: ExecErrorReason,
|
||||
): @Nls String {
|
||||
val commandLine = command.joinToString(" ")
|
||||
val commandLine = exec + args.joinToString(" ")
|
||||
return when (val r = execErrorReason) {
|
||||
is ExecErrorReason.CantStart -> {
|
||||
PyCommunityBundle.message("python.execution.cant.start.error",
|
||||
|
||||
@@ -4,9 +4,11 @@ package com.jetbrains.python.packaging
|
||||
import com.intellij.execution.ExecutionException
|
||||
import com.intellij.execution.process.ProcessOutput
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.platform.eel.provider.asEelPath
|
||||
import com.jetbrains.python.errorProcessing.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
import kotlin.io.path.Path
|
||||
|
||||
/**
|
||||
* Wraps [PyError] for cases where [ExecutionException] is used.
|
||||
@@ -29,7 +31,7 @@ class PyExecutionException private constructor(
|
||||
additionalMessageToUser: @NlsContexts.DialogMessage String?,
|
||||
command: String,
|
||||
args: List<String>,
|
||||
): PyExecutionException = PyExecutionException(ExecError(arrayOf(command) + args.toTypedArray(), ExecErrorReason.Timeout, additionalMessageToUser))
|
||||
): PyExecutionException = PyExecutionException(ExecError(Path(command).asEelPath(), args.toTypedArray(), ExecErrorReason.Timeout, additionalMessageToUser))
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +65,7 @@ class PyExecutionException private constructor(
|
||||
args: List<String>,
|
||||
fixes: List<PyExecutionFix> = listOf<PyExecutionFix>(),
|
||||
) : this(
|
||||
pyError = ExecError(arrayOf(command) + args.toTypedArray(), ExecErrorReason.CantStart(null, startException.localizedMessage), additionalMessage),
|
||||
pyError = ExecError(Path(command).asEelPath(), args.toTypedArray(), ExecErrorReason.CantStart(null, startException.localizedMessage), additionalMessage),
|
||||
fixes = fixes,
|
||||
ioException = startException)
|
||||
|
||||
@@ -82,7 +84,7 @@ class PyExecutionException private constructor(
|
||||
output: ProcessOutput,
|
||||
fixes: List<PyExecutionFix> = listOf<PyExecutionFix>(),
|
||||
) : this(
|
||||
pyError = ExecError(arrayOf(command) + args.toTypedArray(), output.asExecutionFailed()),
|
||||
pyError = ExecError(Path(command).asEelPath(), args.toTypedArray(), output.asExecutionFailed()),
|
||||
fixes = fixes)
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user