From a00b009f777df750adf78ade1142f4a4ea976166 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 21 Aug 2018 10:15:57 -0700 Subject: [PATCH] Add a pylorax.api.version number lorax-composer is in a different package than lorax, so we need to use its version number not lorax's when reporting the API /status/ --- .gitignore | 1 + Makefile | 8 ++++++-- src/pylorax/api/__init__.py | 7 ++++++- src/pylorax/api/server.py | 2 +- tests/pylint/runpylint.py | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bc8af136..c2b602ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.pyc src/pylorax/version.py* +src/pylorax/api/version.py* src/composer/version.py* *.swp .pylint.d/ diff --git a/Makefile b/Makefile index e30aea91..bf26f3c8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PYTHON ?= /usr/bin/python DESTDIR ?= / -PKGNAME = lorax +PKGNAME = lorax-composer VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec) RELEASE = $(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g') TAG = lorax-$(VERSION)-$(RELEASE) @@ -17,7 +17,10 @@ src/composer/version.py: src/pylorax/version.py: echo "num = '$(VERSION)-$(RELEASE)'" > src/pylorax/version.py -all: src/pylorax/version.py src/composer/version.py +src/pylorax/api/version.py: + echo "num = '$(VERSION)-$(RELEASE)'" > src/pylorax/api/version.py + +all: src/pylorax/version.py src/pylorax/api/version.py src/composer/version.py $(PYTHON) setup.py build install: all @@ -47,6 +50,7 @@ test: docs clean: -rm -rf build src/pylorax/version.py + -rm -rf build src/pylorax/api/version.py -rm -rf build src/composer/version.py tag: diff --git a/src/pylorax/api/__init__.py b/src/pylorax/api/__init__.py index 5ee1ec8a..a20f659c 100644 --- a/src/pylorax/api/__init__.py +++ b/src/pylorax/api/__init__.py @@ -17,5 +17,10 @@ # along with this program. If not, see . from pylorax.api.crossdomain import crossdomain -__all__ = ["crossdomain"] +# get the lorax-composer api version +try: + from pylorax.api.version import num as vernum +except ImportError: + vernum = "devel" +__all__ = ["crossdomain", "vernum"] diff --git a/src/pylorax/api/server.py b/src/pylorax/api/server.py index 1bdef8c1..2acc131b 100644 --- a/src/pylorax/api/server.py +++ b/src/pylorax/api/server.py @@ -22,7 +22,7 @@ from flask import Flask, jsonify, redirect, send_from_directory from glob import glob import os -from pylorax import vernum +from pylorax.api import vernum from pylorax.api.crossdomain import crossdomain from pylorax.api.v0 import v0_api from pylorax.sysutils import joinpaths diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py index 13ef7e33..04cc1500 100755 --- a/tests/pylint/runpylint.py +++ b/tests/pylint/runpylint.py @@ -25,6 +25,7 @@ class LoraxLintConfig(PocketLintConfig): self.falsePositives = [ FalsePositive(r"No name 'version' in module 'pylorax'"), FalsePositive(r"Module 'pylorax' has no 'version' member"), + FalsePositive(r"Module 'pylorax.api' has no 'version' member"), FalsePositive(r"Instance of 'int' has no .* member"), FalsePositive(r"Catching too general exception Exception"), FalsePositive(r"^E0712.*: Catching an exception which doesn't inherit from (Base|)Exception: GError$"),