mirror of
https://github.com/frappe/bench.git
synced 2024-11-14 09:14:04 +00:00
fix: check for updates after command execution and handle
requests Exceptions
This commit is contained in:
parent
62f666c481
commit
6ea7d75193
@ -1,3 +1,4 @@
|
|||||||
|
import atexit
|
||||||
import click
|
import click
|
||||||
import os, sys, logging, json, pwd, subprocess
|
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, check_latest_version
|
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
|
||||||
@ -41,8 +42,7 @@ def cli():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# NOTE: this is the main bench command
|
atexit.register(check_latest_version)
|
||||||
check_latest_version()
|
|
||||||
bench_command()
|
bench_command()
|
||||||
except PatchError:
|
except PatchError:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -82,7 +82,12 @@ def safe_decode(string, encoding = 'utf-8'):
|
|||||||
|
|
||||||
|
|
||||||
def check_latest_version():
|
def check_latest_version():
|
||||||
|
try:
|
||||||
pypi_request = requests.get("https://pypi.org/pypi/frappe-bench/json")
|
pypi_request = requests.get("https://pypi.org/pypi/frappe-bench/json")
|
||||||
|
except Exception:
|
||||||
|
# Exceptions thrown are defined in requests.exceptions
|
||||||
|
# ignore checking on all Exceptions
|
||||||
|
return
|
||||||
|
|
||||||
if pypi_request.status_code == 200:
|
if pypi_request.status_code == 200:
|
||||||
pypi_version_str = pypi_request.json().get('info').get('version')
|
pypi_version_str = pypi_request.json().get('info').get('version')
|
||||||
|
Loading…
Reference in New Issue
Block a user