mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
Read character by character and update the spinner every newline or every 100 characters received in the run_install
function.
This commit is contained in:
parent
a3a4113331
commit
2affb111ad
1 changed files with 17 additions and 5 deletions
|
@ -207,24 +207,36 @@ def run_install(cmd):
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
)
|
)
|
||||||
spinner = itertools.cycle(["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
|
spinner = itertools.cycle(["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
|
||||||
|
char_count = 0
|
||||||
|
current_line = ""
|
||||||
|
|
||||||
for line in process.stdout:
|
while True:
|
||||||
output.append(line)
|
char = process.stdout.read(1)
|
||||||
print(f" Installing... {next(spinner)}", end="\r", flush=True)
|
if not char:
|
||||||
|
break
|
||||||
|
|
||||||
|
current_line += char
|
||||||
|
char_count += 1
|
||||||
|
output.append(char)
|
||||||
|
|
||||||
|
if char == '\n' or char_count >= 100:
|
||||||
|
print(f" Installing... {next(spinner)}", end="\r", flush=True)
|
||||||
|
char_count = 0
|
||||||
|
current_line = ""
|
||||||
|
|
||||||
return_code = process.wait()
|
return_code = process.wait()
|
||||||
|
|
||||||
if return_code == 0:
|
if return_code == 0:
|
||||||
print("\rInstallation complete.")
|
print("\rInstallation complete.")
|
||||||
print()
|
print()
|
||||||
return True, output
|
return True, ''.join(output)
|
||||||
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"\nError running pip install: {e}")
|
print(f"\nError running pip install: {e}")
|
||||||
|
|
||||||
print("\nInstallation failed.\n")
|
print("\nInstallation failed.\n")
|
||||||
|
|
||||||
return False, output
|
return False, ''.join(output)
|
||||||
|
|
||||||
|
|
||||||
def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue