mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
feat: check for newer versions on PyPI
This commit is contained in:
parent
5b955897c3
commit
62f666c481
@ -1,6 +1,6 @@
|
||||
import click
|
||||
import os, sys, logging, json, pwd, subprocess
|
||||
from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log, is_dist_editable, find_parent_bench
|
||||
from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log, is_dist_editable, find_parent_bench, check_latest_version
|
||||
from bench.app import get_apps
|
||||
from bench.config.common_site_config import get_config
|
||||
from bench.commands import bench_command
|
||||
@ -42,6 +42,7 @@ def cli():
|
||||
else:
|
||||
try:
|
||||
# NOTE: this is the main bench command
|
||||
check_latest_version()
|
||||
bench_command()
|
||||
except PatchError:
|
||||
sys.exit(1)
|
||||
|
@ -21,6 +21,7 @@ from distutils.spawn import find_executable
|
||||
# imports - third party imports
|
||||
import click
|
||||
import requests
|
||||
from semantic_version import Version
|
||||
from six import iteritems
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
@ -80,6 +81,18 @@ def safe_decode(string, encoding = 'utf-8'):
|
||||
return string
|
||||
|
||||
|
||||
def check_latest_version():
|
||||
pypi_request = requests.get("https://pypi.org/pypi/frappe-bench/json")
|
||||
|
||||
if pypi_request.status_code == 200:
|
||||
pypi_version_str = pypi_request.json().get('info').get('version')
|
||||
pypi_version = Version(pypi_version_str)
|
||||
local_version = Version(bench.__version__)
|
||||
|
||||
if pypi_version > local_version:
|
||||
log("A newer version of bench is available: {0} → {1}".format(local_version, pypi_version))
|
||||
|
||||
|
||||
def get_frappe(bench_path='.'):
|
||||
frappe = get_env_cmd('frappe', bench_path=bench_path)
|
||||
if not os.path.exists(frappe):
|
||||
|
Loading…
Reference in New Issue
Block a user