mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
Only check versions once per day
This commit is contained in:
parent
ed35af44b3
commit
b3f7f0a250
1 changed files with 12 additions and 1 deletions
|
@ -1,12 +1,20 @@
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import packaging.version
|
import packaging.version
|
||||||
import requests
|
|
||||||
|
|
||||||
import aider
|
import aider
|
||||||
|
|
||||||
|
|
||||||
def check_version(print_cmd):
|
def check_version(print_cmd):
|
||||||
|
fname = Path.home() / ".aider/versioncheck"
|
||||||
|
day = 60 * 60 * 24
|
||||||
|
if fname.exists() and time.time() - fname.stat().st_mtime < day:
|
||||||
|
return
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get("https://pypi.org/pypi/aider-chat/json")
|
response = requests.get("https://pypi.org/pypi/aider-chat/json")
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
@ -27,6 +35,9 @@ def check_version(print_cmd):
|
||||||
else:
|
else:
|
||||||
print_cmd(f"{py} -m pip install --upgrade aider-chat")
|
print_cmd(f"{py} -m pip install --upgrade aider-chat")
|
||||||
|
|
||||||
|
if not fname.parent.exists():
|
||||||
|
fname.parent.mkdir()
|
||||||
|
fname.touch()
|
||||||
return is_update_available
|
return is_update_available
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print_cmd(f"Error checking pypi for new version: {err}")
|
print_cmd(f"Error checking pypi for new version: {err}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue