From b38b89a17b448a022d37f926c54cacafa56198ab Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Tue, 2 Feb 2016 15:13:22 +0000 Subject: [PATCH 1/3] Updated status endpoint info from travis build time and commit. --- app/__init__.py | 18 ++++++++++-------- app/status/views/healthcheck.py | 4 +++- app/version.py | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 3ffd6e073..013705e84 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -173,11 +173,13 @@ def register_errorhandlers(application): application.errorhandler(errcode)(render_error) -def get_app_version(): - _version_re = re.compile(r'__version__\s+=\s+(.*)') - version = 'n/a' - dir_path = os.path.dirname(os.path.abspath(__file__)) - with open(os.path.join(dir_path, 'version.py'), 'rb') as f: - version = str(ast.literal_eval(_version_re.search( - f.read().decode('utf-8')).group(1))) - return version +def get_api_version(): + build = 'n/a' + build_time = "n/a" + try: + from app import version + build = version.__build__ + build_time = version.__time__ + except: + pass + return build, build_time diff --git a/app/status/views/healthcheck.py b/app/status/views/healthcheck.py index d291b39a4..4de7a67fc 100644 --- a/app/status/views/healthcheck.py +++ b/app/status/views/healthcheck.py @@ -11,6 +11,8 @@ def status(): api_status = status_api_client.get_status() except: api_status = 'n/a' + build, build_time = get_api_version() return jsonify(status="ok", app_version=get_app_version(), - api_status=api_status), 200 + api_build=build, + api_built_time=build_time), 200 diff --git a/app/version.py b/app/version.py index df9144c54..62a3e5dfd 100644 --- a/app/version.py +++ b/app/version.py @@ -1 +1,2 @@ -__version__ = '0.1.1' +__build__ = "" +__time__ = "" From 5d88ecc866b3eedb08164a26e95e2b631b8c0562 Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Tue, 2 Feb 2016 16:42:57 +0000 Subject: [PATCH 2/3] Bug fix for mis-spelled func names. --- app/__init__.py | 2 +- app/status/views/healthcheck.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 013705e84..f28db4369 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -173,7 +173,7 @@ def register_errorhandlers(application): application.errorhandler(errcode)(render_error) -def get_api_version(): +def get_app_version(): build = 'n/a' build_time = "n/a" try: diff --git a/app/status/views/healthcheck.py b/app/status/views/healthcheck.py index 4de7a67fc..809ffcd6c 100644 --- a/app/status/views/healthcheck.py +++ b/app/status/views/healthcheck.py @@ -11,7 +11,7 @@ def status(): api_status = status_api_client.get_status() except: api_status = 'n/a' - build, build_time = get_api_version() + build, build_time = get_app_version() return jsonify(status="ok", app_version=get_app_version(), api_build=build, From c7ab8bd957c4650916cac817baa1baee52c49a8f Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Tue, 2 Feb 2016 16:44:42 +0000 Subject: [PATCH 3/3] Status structure updated. --- app/status/views/healthcheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/status/views/healthcheck.py b/app/status/views/healthcheck.py index 809ffcd6c..24337761b 100644 --- a/app/status/views/healthcheck.py +++ b/app/status/views/healthcheck.py @@ -13,6 +13,6 @@ def status(): api_status = 'n/a' build, build_time = get_app_version() return jsonify(status="ok", - app_version=get_app_version(), + api_status=api_status, api_build=build, api_built_time=build_time), 200