mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
pty.spawn is not good
This commit is contained in:
parent
656d224bf5
commit
a2cb660183
1 changed files with 24 additions and 20 deletions
|
@ -29,15 +29,34 @@ class EditBlockCoder(Coder):
|
||||||
return edits
|
return edits
|
||||||
|
|
||||||
def run_interactive_subprocess(self, command):
|
def run_interactive_subprocess(self, command):
|
||||||
|
dump(repr(command))
|
||||||
if os.name == "posix": # Unix-like systems (Linux, macOS)
|
if os.name == "posix": # Unix-like systems (Linux, macOS)
|
||||||
import pty
|
return subprocess.run(command, shell=True)
|
||||||
|
# return pty.spawn(command)
|
||||||
return pty.spawn(command)
|
|
||||||
elif os.name == "nt": # Windows
|
elif os.name == "nt": # Windows
|
||||||
return subprocess.run(command, shell=True)
|
return subprocess.run(command, shell=True)
|
||||||
else:
|
else:
|
||||||
raise OSError("Unsupported operating system")
|
raise OSError("Unsupported operating system")
|
||||||
|
|
||||||
|
def handle_shell_commands(self, commands_str):
|
||||||
|
commands = commands_str.strip().splitlines()
|
||||||
|
if not self.io.confirm_ask("Run shell command(s)?", subject="\n".join(commands)):
|
||||||
|
return
|
||||||
|
|
||||||
|
for command in commands:
|
||||||
|
command = command.strip()
|
||||||
|
if not command or command.startswith("#"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.io.tool_output()
|
||||||
|
self.io.tool_output(f"Running {command}")
|
||||||
|
try:
|
||||||
|
# Add the command to input history
|
||||||
|
self.io.add_to_input_history(f"/run {command.strip()}")
|
||||||
|
self.run_interactive_subprocess(command)
|
||||||
|
except Exception as e:
|
||||||
|
self.io.tool_error(f"Error running command '{command}': {str(e)}")
|
||||||
|
|
||||||
def apply_edits(self, edits):
|
def apply_edits(self, edits):
|
||||||
failed = []
|
failed = []
|
||||||
passed = []
|
passed = []
|
||||||
|
@ -67,6 +86,8 @@ class EditBlockCoder(Coder):
|
||||||
else:
|
else:
|
||||||
failed.append(edit)
|
failed.append(edit)
|
||||||
|
|
||||||
|
dump(failed)
|
||||||
|
dump(passed)
|
||||||
if not failed:
|
if not failed:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -568,20 +589,3 @@ def main():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
def handle_shell_commands(self, commands_str):
|
|
||||||
commands = commands_str.strip().splitlines()
|
|
||||||
if self.io.confirm_ask("Run shell command(s)?", subject="\n".join(commands)):
|
|
||||||
for command in commands:
|
|
||||||
command = command.strip()
|
|
||||||
if not command or command.startswith("#"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.io.tool_output()
|
|
||||||
self.io.tool_output(f"Running {command}")
|
|
||||||
try:
|
|
||||||
# Add the command to input history
|
|
||||||
self.io.add_to_input_history(f"/run {command.strip()}")
|
|
||||||
self.run_interactive_subprocess(command.split())
|
|
||||||
except Exception as e:
|
|
||||||
self.io.tool_error(f"Error running command '{command}': {str(e)}")
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue