aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/util.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-12-24 10:07:02 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-12-24 10:17:48 -0500
commit451ffd567d3a2b4871229681ec0449b87cc519f5 (patch)
tree3ba8479ec76d029b9933b3c002d0c3b1681ac1ae /klippy/util.py
parentf3a49604f1fdbefc87010fb2a51070c7421aa7f0 (diff)
downloadkutter-451ffd567d3a2b4871229681ec0449b87cc519f5.tar.gz
kutter-451ffd567d3a2b4871229681ec0449b87cc519f5.tar.xz
kutter-451ffd567d3a2b4871229681ec0449b87cc519f5.zip
klippy: Log the host software git version at startup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/util.py')
-rw-r--r--klippy/util.py19
1 files changed, 17 insertions, 2 deletions
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 <kevin@koconnor.net>
#
# 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),))