From 33c14bfb16a18f9dd44e8c0616d23ebce6114a7e Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 21 Sep 2017 00:49:12 +0200 Subject: T401: add functions for reading VyOS version data. --- python/vyos/util.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python') diff --git a/python/vyos/util.py b/python/vyos/util.py index a1a835de6..b3eff3965 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -17,6 +17,21 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import json class ConfigError(Exception): pass + + +def get_version_data(file='/opt/vyatta/etc/version.json'): + with open(file, 'r') as f: + version_data = json.load(f) + return version_data + +def get_version(file=None): + version_data = None + if file: + version_data = get_version_data(file=file) + else: + version_data = get_version_data() + return version_data["version"] -- cgit v1.2.3