From 7cb7a5f96f4308dc1cb01033aa383dfcf2fc6e98 Mon Sep 17 00:00:00 2001 From: Greg Meyer Date: Thu, 18 Aug 2022 09:35:39 -0700 Subject: [PATCH] fix broken version check --- src/dynamite/__init__.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/dynamite/__init__.py b/src/dynamite/__init__.py index 94fcf96..d65d7e4 100644 --- a/src/dynamite/__init__.py +++ b/src/dynamite/__init__.py @@ -218,30 +218,27 @@ def check_version(): # finally do the check - branch = bbuild.get_build_branch() - url = 'https://api.github.com/repos/GregDMeyer/dynamite/git/refs/heads/{branch}' - url = url.format(branch=branch) + url = 'https://api.github.com/repos/GregDMeyer/dynamite/git/refs/heads/' + url += bbuild.get_build_branch() try: with request.urlopen(url, timeout=1) as url_req: - try: - data = json.load(url_req) - except TypeError: # python < 3.6 - data = json.loads(url_req.readall().decode('utf-8')) - - commit = data['object']['sha'] - - build_commit = bbuild.get_build_version() - if not commit.startswith(build_commit): - if 'DNM_DOCKER' in environ: - update_msg = 'Please pull the latest image from DockerHub.' - else: - update_msg = 'Please update!' - - print('Changes have been pushed to GitHub since dynamite was ' - 'installed.\n' + update_msg, file=stderr) + data = json.load(url_req) # in general, catching all exceptions is a bad idea. but here, no matter # what happens we just want to give up on the check except: - pass + return + + commit = data['object']['sha'] + + if not commit.startswith(bbuild.get_build_commit()): + print('Changes have been pushed to GitHub since dynamite was ' + 'installed.\n', file=stderr) + + if 'DNM_DOCKER' in environ: + update_msg = 'Please pull the latest image from DockerHub.' + else: + update_msg = 'Please update!' + + print(update_msg, file=stderr)