add git version printing where available.

This commit is contained in:
clinton-hall 2014-04-11 11:57:13 +09:30
commit 1a96e190e5

View file

@ -1,6 +1,7 @@
import os import os
import shutil import shutil
import lib.configobj import lib.configobj
from subprocess import check_output, CalledProcessError
from lib.configobj import ConfigObj from lib.configobj import ConfigObj
from itertools import chain from itertools import chain
@ -41,6 +42,14 @@ class config(original_ConfigObj):
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg") LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample") SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample")
try:
repo = check_output(["git", "config", "--get", "remote.origin.url"]).splitlines()[0]
branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).splitlines()[0]
hash = check_output(["git", "rev-parse", "--short", "HEAD"]).splitlines()[0]
NZBTOMEDIA_VERSION = 'repo:' + repo + ' branch:' + branch + ' hash: ' + hash
except CalledProcessError:
pass
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
if len(args) == 0: if len(args) == 0:
args = (self.CONFIG_FILE,) args = (self.CONFIG_FILE,)