mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-07 13:15:00 +00:00
feat: add error handling and flexible error reporting to run_cmd
This commit is contained in:
parent
db7590048e
commit
d8639bac48
1 changed files with 12 additions and 4 deletions
|
@ -7,11 +7,19 @@ from io import BytesIO
|
|||
import pexpect
|
||||
|
||||
|
||||
def run_cmd(command, verbose=False):
|
||||
if sys.stdin.isatty() and hasattr(pexpect, "spawn") and platform.system() != "Windows":
|
||||
return run_cmd_pexpect(command, verbose)
|
||||
def run_cmd(command, verbose=False, error_print=None):
|
||||
try:
|
||||
if sys.stdin.isatty() and hasattr(pexpect, "spawn") and platform.system() != "Windows":
|
||||
return run_cmd_pexpect(command, verbose)
|
||||
|
||||
return run_cmd_subprocess(command, verbose)
|
||||
return run_cmd_subprocess(command, verbose)
|
||||
except OSError as e:
|
||||
error_message = f"OSError occurred while running command '{command}': {str(e)}"
|
||||
if error_print is None:
|
||||
print(error_message)
|
||||
else:
|
||||
error_print(error_message)
|
||||
return 1, error_message
|
||||
|
||||
|
||||
def run_cmd_subprocess(command, verbose=False):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue