Skip to content

Commit

Permalink
fix: check for updates after command execution and handle
Browse files Browse the repository at this point in the history
requests Exceptions
  • Loading branch information
gavindsouza committed Apr 2, 2020
1 parent 62f666c commit 6ea7d75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bench/cli.py
@@ -1,3 +1,4 @@
import atexit
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, check_latest_version
Expand Down Expand Up @@ -41,8 +42,7 @@ def cli():

else:
try:
# NOTE: this is the main bench command
check_latest_version()
atexit.register(check_latest_version)
bench_command()
except PatchError:
sys.exit(1)
Expand Down
7 changes: 6 additions & 1 deletion bench/utils.py
Expand Up @@ -82,7 +82,12 @@ def safe_decode(string, encoding = 'utf-8'):


def check_latest_version():
pypi_request = requests.get("https://pypi.org/pypi/frappe-bench/json")
try:
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:
pypi_version_str = pypi_request.json().get('info').get('version')
Expand Down

0 comments on commit 6ea7d75

Please sign in to comment.