mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
feat: add verbose output to check_and_load_imports function
This commit is contained in:
parent
b4389f98fb
commit
aeea629d17
1 changed files with 19 additions and 3 deletions
|
@ -4,6 +4,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
import traceback
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import git
|
import git
|
||||||
|
@ -686,7 +687,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
if args.exit:
|
if args.exit:
|
||||||
return
|
return
|
||||||
|
|
||||||
check_and_load_imports(io)
|
check_and_load_imports(io, verbose=args.verbose)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -706,30 +707,45 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_and_load_imports(io):
|
def check_and_load_imports(io, verbose=False):
|
||||||
|
|
||||||
installs_file = Path.home() / ".aider" / "installs.json"
|
installs_file = Path.home() / ".aider" / "installs.json"
|
||||||
key = (__version__, sys.executable)
|
key = (__version__, sys.executable)
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
io.tool_output(f"Checking imports for version {__version__} and executable {sys.executable}")
|
||||||
|
io.tool_output(f"Installs file: {installs_file}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if installs_file.exists():
|
if installs_file.exists():
|
||||||
with open(installs_file, "r") as f:
|
with open(installs_file, "r") as f:
|
||||||
installs = json.load(f)
|
installs = json.load(f)
|
||||||
|
if verbose:
|
||||||
|
io.tool_output("Installs file exists and loaded")
|
||||||
else:
|
else:
|
||||||
installs = {}
|
installs = {}
|
||||||
|
if verbose:
|
||||||
|
io.tool_output("Installs file does not exist, creating new dictionary")
|
||||||
|
|
||||||
if str(key) not in installs:
|
if str(key) not in installs:
|
||||||
|
if verbose:
|
||||||
|
io.tool_output("First run for this version and executable, loading imports synchronously")
|
||||||
load_slow_imports()
|
load_slow_imports()
|
||||||
installs[str(key)] = True
|
installs[str(key)] = True
|
||||||
installs_file.parent.mkdir(parents=True, exist_ok=True)
|
installs_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(installs_file, "w") as f:
|
with open(installs_file, "w") as f:
|
||||||
json.dump(installs, f, indent=4)
|
json.dump(installs, f, indent=4)
|
||||||
|
if verbose:
|
||||||
|
io.tool_output("Imports loaded and installs file updated")
|
||||||
else:
|
else:
|
||||||
|
if verbose:
|
||||||
|
io.tool_output("Not first run, loading imports in background thread")
|
||||||
thread = threading.Thread(target=load_slow_imports)
|
thread = threading.Thread(target=load_slow_imports)
|
||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
thread.start()
|
thread.start()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
io.tool_warning(f"Error in check_and_load_imports: {e}", file=sys.stderr)
|
io.tool_warning(f"Error in check_and_load_imports: {e}", file=sys.stderr)
|
||||||
|
if verbose:
|
||||||
|
io.tool_output(f"Full exception details: {traceback.format_exc()}")
|
||||||
|
|
||||||
|
|
||||||
def load_slow_imports():
|
def load_slow_imports():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue