mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-08 05:34:59 +00:00
feat: implement real-time output display in run_cmd_subprocess
This commit is contained in:
parent
64b05a9971
commit
afa7d02906
1 changed files with 11 additions and 2 deletions
|
@ -18,7 +18,7 @@ def run_cmd(command):
|
|||
|
||||
def run_cmd_subprocess(command):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
|
@ -26,8 +26,17 @@ def run_cmd_subprocess(command):
|
|||
shell=True,
|
||||
encoding=sys.stdout.encoding,
|
||||
errors="replace",
|
||||
bufsize=1,
|
||||
universal_newlines=True
|
||||
)
|
||||
return result.returncode, result.stdout
|
||||
|
||||
output = []
|
||||
for line in process.stdout:
|
||||
print(line, end='') # Print the line in real-time
|
||||
output.append(line) # Store the line for later use
|
||||
|
||||
process.wait()
|
||||
return process.returncode, ''.join(output)
|
||||
except Exception as e:
|
||||
return 1, str(e)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue