include current Git HEAD in debug output

This commit is contained in:
Mike Fährmann 2018-07-17 22:44:32 +02:00
parent c9f70e0a19
commit 39f609b4c6
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -238,8 +238,24 @@ def main():
config.set(("output", "mode"), "null") config.set(("output", "mode"), "null")
elif args.loglevel <= logging.DEBUG: elif args.loglevel <= logging.DEBUG:
import platform import platform
import subprocess
import os.path
import requests import requests
log.debug("Version %s", __version__)
head = ""
try:
out, err = subprocess.Popen(
("git", "rev-parse", "--short", "HEAD"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=os.path.dirname(os.path.abspath(__file__)),
).communicate()
if out and not err:
head = " - Git HEAD: " + out.decode().rstrip()
except (OSError, subprocess.SubprocessError):
pass
log.debug("Version %s%s", __version__, head)
log.debug("Python %s - %s", log.debug("Python %s - %s",
platform.python_version(), platform.platform()) platform.python_version(), platform.platform())
try: try: