From d1a9309b036d3542b93b8c0fdabd8a3abf660128 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Wed, 26 Nov 2014 15:58:28 -0800 Subject: [PATCH] fix #125: handle 'git log' failures gracefully --- plugins/misc.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/misc.py b/plugins/misc.py index da0924b..abd0b3c 100644 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -8,13 +8,15 @@ socket.setdefaulttimeout(10) # global setting def get_version(): - p = subprocess.Popen(['git', 'log', '--oneline'], stdout=subprocess.PIPE) - stdout, _ = p.communicate() - p.wait() - - revnumber = len(stdout.splitlines()) - - shorthash = stdout.split(None, 1)[0] + try: + stdout = subprocess.check_output(['git', 'log', '--format=%h']) + except: + revnumber = 0 + shorthash = '????' + else: + revs = stdout.splitlines() + revnumber = len(revs) + shorthash = revs[0] http.ua_skybot = 'Skybot/r%d %s (http://github.com/rmmh/skybot)' \ % (revnumber, shorthash)