diff --git a/python/python-exec-service/resources/messages/PyExecBundle.properties b/python/python-exec-service/resources/messages/PyExecBundle.properties index 0a8dfe7bec74..2f3b0f61fe0d 100644 --- a/python/python-exec-service/resources/messages/PyExecBundle.properties +++ b/python/python-exec-service/resources/messages/PyExecBundle.properties @@ -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} \ No newline at end of file +py.exec.fileNotFound=File {0} not found on {1} + +py.exec.target.name.default="Local" \ No newline at end of file diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/impl/logging.kt b/python/python-exec-service/src/com/intellij/python/community/execService/impl/logging.kt index ccce7fbeb5de..2c353372d441 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/impl/logging.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/impl/logging.kt @@ -49,6 +49,7 @@ data class LoggedProcess( val exe: LoggedProcessExe, val args: List, val env: Map, + val target: String, val lines: SharedFlow, val exitInfo: MutableStateFlow, ) { @@ -111,6 +112,7 @@ class LoggingProcess( exe: Exe, args: List, env: Map, + target: String, ) : Process() { val loggedProcess: LoggedProcess @@ -139,6 +141,7 @@ class LoggingProcess( ), args, env, + target, linesFlow, exitInfoFlow, ) diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/ProcessLauncher.kt b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/ProcessLauncher.kt index ac086210fd58..0d0781f26618 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/ProcessLauncher.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/ProcessLauncher.kt @@ -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 val processFunctions: ProcessFunctions val scopeToBind: CoroutineScope - val env: Map - val cwd: String? + val info: ProcessCommandsInfo } +internal data class ProcessCommandsInfo( + val env: Map, + val cwd: String?, + val target: String, +) + internal data class LaunchRequest( val scopeToBind: CoroutineScope, val args: Args, diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/eel.kt b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/eel.kt index d2651db2e369..b5f10311d734 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/eel.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/eel.kt @@ -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, - override val env: Map, + private val env: Map, 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 { var workDir = binOnEel.workDir workDir = if (workDir != null && !workDir.isAbsolute) workDir.toRealPath() else workDir diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/targets.kt b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/targets.kt index 394b1d65b336..8a458c97748a 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/targets.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/targets.kt @@ -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 @@ -95,11 +96,12 @@ private class TargetProcessCommands( private val targetEnv: TargetEnvironment, private val cmdLine: TargetedCommandLine, ) : ProcessCommands { - override val env: Map - 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 diff --git a/python/python-exec-service/tests/com/intellij/python/junit5Tests/unit/LoggingTest.kt b/python/python-exec-service/tests/com/intellij/python/junit5Tests/unit/LoggingTest.kt index b90191af20d5..fc4a8639c5b8 100644 --- a/python/python-exec-service/tests/com/intellij/python/junit5Tests/unit/LoggingTest.kt +++ b/python/python-exec-service/tests/com/intellij/python/junit5Tests/unit/LoggingTest.kt @@ -181,6 +181,7 @@ private class LoggingTest { ), args = command.drop(1), env = mapOf(), + target = "Local", lines = MutableSharedFlow(), exitInfo = MutableStateFlow(null), ) @@ -234,7 +235,8 @@ private class LoggingTest { cwd, Exe.fromString(pathToExe), args, - env + env, + "Local", ) } } diff --git a/python/python-process-output/impl/resources/messages/ProcessOutputBundle.properties b/python/python-process-output/impl/resources/messages/ProcessOutputBundle.properties index 4c84e37b719d..8918679e020d 100644 --- a/python/python-process-output/impl/resources/messages/ProcessOutputBundle.properties +++ b/python/python-process-output/impl/resources/messages/ProcessOutputBundle.properties @@ -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 diff --git a/python/python-process-output/impl/src/com/intellij/python/processOutput/impl/ui/components/OutputSection.kt b/python/python-process-output/impl/src/com/intellij/python/processOutput/impl/ui/components/OutputSection.kt index dab1a1d1ea19..9a9c93d04ffe 100644 --- a/python/python-process-output/impl/src/com/intellij/python/processOutput/impl/ui/components/OutputSection.kt +++ b/python/python-process-output/impl/src/com/intellij/python/processOutput/impl/ui/components/OutputSection.kt @@ -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" }, diff --git a/python/python-process-output/impl/test/com/intellij/python/processOutput/impl/util.kt b/python/python-process-output/impl/test/com/intellij/python/processOutput/impl/util.kt index 77fcede4b6de..c32d7e6be35b 100644 --- a/python/python-process-output/impl/test/com/intellij/python/processOutput/impl/util.kt +++ b/python/python-process-output/impl/test/com/intellij/python/processOutput/impl/util.kt @@ -171,6 +171,7 @@ internal abstract class ProcessOutputTest { ), args = command.drop(1), env = mapOf(), + target = "Local", lines = MutableSharedFlow(), exitInfo = MutableStateFlow(null), )