1 from typing
import List
2 from pathlib
import Path
6 from threading
import Thread
8 from .run_logger
import runLogger
9 from ..logging
import LogSeverity
12 def captureRunStdout(process: subprocess.Popen) ->
None:
13 stdout = process.stdout
15 raise ValueError(
"stdout is None for subprocess")
17 while process.poll()
is None:
18 line: str = stdout.readline().decode(
"UTF-8")
19 runLogger.logProcessOutput(line)
22 def captureRunStderr(process: subprocess.Popen, isEnabled: bool) ->
None:
23 stderr = process.stderr
25 raise ValueError(
"stderr is None for subprocess")
28 while process.poll()
is None:
29 line: str = stderr.readline().decode(
"UTF-8")
34 if isEnabled
and process.returncode == 0:
35 severity = LogSeverity.warning
37 severity = LogSeverity.fatal
40 severity = LogSeverity.debug
42 runLogger.logProcessOutput(line, severity)
45 def executeRunLocally(
48 cwd: Path = Path.cwd()
51 process = subprocess.Popen(
55 stdout = subprocess.PIPE,
56 stderr = subprocess.PIPE
61 target = captureRunStdout,
63 name =
"Process stdout reader"
69 target = captureRunStderr,
70 args = (process, captureErr),
71 name =
"Process stderr reader"