mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
[pycharm] PY-85618 Expose target information
Merge-request: IJ-MR-182369 Merged-by: David Lysenko <david.lysenko@jetbrains.com> (cherry picked from commit 3a29771c841058d1591ae79eee71887ce495d15e) IJ-MR-182369 GitOrigin-RevId: 7e24ff6fb745b422a9f949b46b27c692d7bbd3a2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
41506368ca
commit
443406f930
@@ -3,4 +3,6 @@ py.exec.defaultName.process=Process {0}
|
||||
py.exec.start.error={0} Failed to Start: {1} (Code {2})
|
||||
py.exec.timeout.error={0} Timed out (Run More Than {1})
|
||||
py.exec.exitCode.error={0} Exited with {1}
|
||||
py.exec.fileNotFound=File {0} not found on {1}
|
||||
py.exec.fileNotFound=File {0} not found on {1}
|
||||
|
||||
py.exec.target.name.default="Local"
|
||||
@@ -49,6 +49,7 @@ data class LoggedProcess(
|
||||
val exe: LoggedProcessExe,
|
||||
val args: List<String>,
|
||||
val env: Map<String, String>,
|
||||
val target: String,
|
||||
val lines: SharedFlow<LoggedProcessLine>,
|
||||
val exitInfo: MutableStateFlow<LoggedProcessExitInfo?>,
|
||||
) {
|
||||
@@ -111,6 +112,7 @@ class LoggingProcess(
|
||||
exe: Exe,
|
||||
args: List<String>,
|
||||
env: Map<String, String>,
|
||||
target: String,
|
||||
) : Process() {
|
||||
val loggedProcess: LoggedProcess
|
||||
|
||||
@@ -139,6 +141,7 @@ class LoggingProcess(
|
||||
),
|
||||
args,
|
||||
env,
|
||||
target,
|
||||
linesFlow,
|
||||
exitInfoFlow,
|
||||
)
|
||||
|
||||
@@ -27,10 +27,11 @@ internal class ProcessLauncher(
|
||||
it,
|
||||
processCommands.scopeToBind.coroutineContext[TraceContext.Key],
|
||||
Clock.System.now(),
|
||||
processCommands.cwd,
|
||||
processCommands.info.cwd,
|
||||
exeForError,
|
||||
args,
|
||||
processCommands.env,
|
||||
processCommands.info.env,
|
||||
processCommands.info.target,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,10 +44,15 @@ internal interface ProcessCommands {
|
||||
suspend fun start(): Result<Process, ExecErrorReason.CantStart>
|
||||
val processFunctions: ProcessFunctions
|
||||
val scopeToBind: CoroutineScope
|
||||
val env: Map<String, String>
|
||||
val cwd: String?
|
||||
val info: ProcessCommandsInfo
|
||||
}
|
||||
|
||||
internal data class ProcessCommandsInfo(
|
||||
val env: Map<String, String>,
|
||||
val cwd: String?,
|
||||
val target: String,
|
||||
)
|
||||
|
||||
internal data class LaunchRequest(
|
||||
val scopeToBind: CoroutineScope,
|
||||
val args: Args,
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.platform.eel.EelProcess
|
||||
import com.intellij.platform.eel.ExecuteProcessException
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import com.intellij.platform.eel.provider.asEelPath
|
||||
import com.intellij.platform.eel.provider.getEelDescriptor
|
||||
import com.intellij.platform.eel.provider.utils.EelPathUtils
|
||||
import com.intellij.platform.eel.provider.utils.ProcessFunctions
|
||||
import com.intellij.platform.eel.spawnProcess
|
||||
@@ -15,7 +16,6 @@ import com.jetbrains.python.Result
|
||||
import com.jetbrains.python.errorProcessing.Exe
|
||||
import com.jetbrains.python.errorProcessing.ExecErrorReason
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.pathString
|
||||
|
||||
internal suspend fun createProcessLauncherOnEel(binOnEel: BinOnEel, launchRequest: LaunchRequest): ProcessLauncher {
|
||||
@@ -41,20 +41,23 @@ private class EelProcessCommands(
|
||||
private val binOnEel: BinOnEel,
|
||||
private val path: EelPath,
|
||||
private val args: List<String>,
|
||||
override val env: Map<String, String>,
|
||||
private val env: Map<String, String>,
|
||||
private val tty: TtySize?,
|
||||
) : ProcessCommands {
|
||||
private var eelProcess: EelProcess? = null
|
||||
|
||||
override val cwd: String?
|
||||
get() = binOnEel.workDir?.toRealPath()?.pathString
|
||||
override val info: ProcessCommandsInfo
|
||||
get() = ProcessCommandsInfo(
|
||||
env = env,
|
||||
cwd = binOnEel.workDir?.toRealPath()?.pathString,
|
||||
target = binOnEel.path.getEelDescriptor().machine.name,
|
||||
)
|
||||
|
||||
override val processFunctions: ProcessFunctions = ProcessFunctions(
|
||||
waitForExit = { eelProcess?.exitCode?.await() },
|
||||
killProcess = { eelProcess?.kill() }
|
||||
)
|
||||
|
||||
|
||||
override suspend fun start(): Result<Process, ExecErrorReason.CantStart> {
|
||||
var workDir = binOnEel.workDir
|
||||
workDir = if (workDir != null && !workDir.isAbsolute) workDir.toRealPath() else workDir
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.intellij.platform.eel.provider.utils.ProcessFunctions
|
||||
import com.intellij.platform.eel.provider.utils.bindProcessToScopeImpl
|
||||
import com.intellij.python.community.execService.BinOnTarget
|
||||
import com.intellij.python.community.execService.ExecuteGetProcessError
|
||||
import com.intellij.python.community.execService.impl.PyExecBundle
|
||||
import com.intellij.python.community.execService.spi.TargetEnvironmentRequestHandler
|
||||
import com.intellij.remoteServer.util.ServerRuntimeException
|
||||
import com.jetbrains.python.Result
|
||||
@@ -92,11 +93,12 @@ private class TargetProcessCommands(
|
||||
private val targetEnv: TargetEnvironment,
|
||||
private val cmdLine: TargetedCommandLine,
|
||||
) : ProcessCommands {
|
||||
override val env: Map<String, String>
|
||||
get() = cmdLine.environmentVariables
|
||||
|
||||
override val cwd: String?
|
||||
get() = cmdLine.workingDirectory
|
||||
override val info: ProcessCommandsInfo
|
||||
get() = ProcessCommandsInfo(
|
||||
env = cmdLine.environmentVariables,
|
||||
cwd = cmdLine.workingDirectory,
|
||||
target = targetEnv.request.configuration?.displayName ?: PyExecBundle.message("py.exec.target.name.default")
|
||||
)
|
||||
|
||||
private var process: Process? = null
|
||||
|
||||
|
||||
@@ -180,6 +180,7 @@ private class LoggingTest {
|
||||
),
|
||||
args = command.drop(1),
|
||||
env = mapOf(),
|
||||
target = "Local",
|
||||
lines = MutableSharedFlow(),
|
||||
exitInfo = MutableStateFlow(null),
|
||||
)
|
||||
@@ -233,7 +234,8 @@ private class LoggingTest {
|
||||
cwd,
|
||||
Exe.fromString(pathToExe),
|
||||
args,
|
||||
env
|
||||
env,
|
||||
"Local",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ process.output.output.sections.info.started=started
|
||||
process.output.output.sections.info.command=command
|
||||
process.output.output.sections.info.pid=pid
|
||||
process.output.output.sections.info.cwd=cwd
|
||||
process.output.output.sections.info.target=target
|
||||
process.output.output.sections.info.env=env
|
||||
|
||||
process.output.output.sections.output=Process Output
|
||||
|
||||
@@ -137,6 +137,10 @@ internal fun OutputSection(controller: ProcessOutputController) {
|
||||
cwd,
|
||||
)
|
||||
},
|
||||
InfoLine.Single(
|
||||
message("process.output.output.sections.info.target"),
|
||||
it.target,
|
||||
),
|
||||
InfoLine.Multi(
|
||||
message("process.output.output.sections.info.env"),
|
||||
it.env.entries.map { (key, value) -> "$key=$value" },
|
||||
|
||||
@@ -171,6 +171,7 @@ internal abstract class ProcessOutputTest {
|
||||
),
|
||||
args = command.drop(1),
|
||||
env = mapOf(),
|
||||
target = "Local",
|
||||
lines = MutableSharedFlow(),
|
||||
exitInfo = MutableStateFlow(null),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user