From b38b89a17b448a022d37f926c54cacafa56198ab Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Tue, 2 Feb 2016 15:13:22 +0000 Subject: [PATCH] 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__ = ""