From f1e8bfb8a766035d2556066b5522c6a51a3df9d1 Mon Sep 17 00:00:00 2001 From: Evax Software Date: Tue, 15 May 2012 09:58:45 +0200 Subject: [PATCH] improve version printing when run from a checkout --- lib/cdist/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/cdist/__init__.py b/lib/cdist/__init__.py index bd8e6483..3bde31ad 100644 --- a/lib/cdist/__init__.py +++ b/lib/cdist/__init__.py @@ -19,7 +19,17 @@ # # -VERSION = "2.0.9" +import os +import subprocess + +try: + with open(os.devnull, 'w') as devnull: + here = os.path.dirname(os.path.realpath(__file__)) + VERSION = subprocess.check_output( + 'cd "%s" && git describe' % here, + stderr=devnull, shell=True).decode('utf-8') +except: + VERSION = "2.0.9" BANNER = """ .. . .x+=:. s @@ -38,8 +48,6 @@ BANNER = """ DOT_CDIST = ".cdist" -import os - class Error(Exception): """Base exception class for this project""" pass