From 451ffd567d3a2b4871229681ec0449b87cc519f5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 24 Dec 2016 10:07:02 -0500 Subject: klippy: Log the host software git version at startup Signed-off-by: Kevin O'Connor --- klippy/util.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'klippy/util.py') diff --git a/klippy/util.py b/klippy/util.py index 6bbfd9af..9daf75cd 100644 --- a/klippy/util.py +++ b/klippy/util.py @@ -3,8 +3,7 @@ # Copyright (C) 2016 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. - -import os, pty, fcntl, termios, signal +import os, pty, fcntl, termios, signal, logging, subprocess, traceback, shlex # Return the SIGINT interrupt handler back to the OS default def fix_sigint(): @@ -36,3 +35,19 @@ def create_pty(ptyname): old[3] = old[3] & ~termios.ECHO termios.tcsetattr(mfd, termios.TCSADRAIN, old) return mfd + +def report_git_version(): + # Obtain version info from "git" program + if not os.path.exists('.git'): + logging.debug("No '.git' file/directory found") + return + prog = "git describe --tags --long --dirty" + try: + process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE) + output = process.communicate()[0] + retcode = process.poll() + except OSError: + logging.debug("Exception on run: %s" % (traceback.format_exc(),)) + return + ver = output.strip() + logging.info("Git version: %s" % (repr(ver),)) -- cgit v1.2.3-70-g09d2