mirror of https://github.com/Desuuuu/klipper.git
util: Use path of script instead of current directory for git version
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
3a7a77d49e
commit
eebaeeff96
|
@ -3,7 +3,8 @@
|
||||||
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import os, pty, fcntl, termios, signal, logging, subprocess, traceback, shlex
|
import sys, os, pty, fcntl, termios, signal, logging
|
||||||
|
import subprocess, traceback, shlex
|
||||||
|
|
||||||
# Return the SIGINT interrupt handler back to the OS default
|
# Return the SIGINT interrupt handler back to the OS default
|
||||||
def fix_sigint():
|
def fix_sigint():
|
||||||
|
@ -38,10 +39,11 @@ def create_pty(ptyname):
|
||||||
|
|
||||||
def get_git_version():
|
def get_git_version():
|
||||||
# Obtain version info from "git" program
|
# Obtain version info from "git" program
|
||||||
if not os.path.exists('.git'):
|
gitdir = os.path.join(sys.path[0], '..', '.git')
|
||||||
|
if not os.path.exists(gitdir):
|
||||||
logging.debug("No '.git' file/directory found")
|
logging.debug("No '.git' file/directory found")
|
||||||
return "?"
|
return "?"
|
||||||
prog = "git describe --tags --long --dirty"
|
prog = "git --git-dir=%s describe --tags --long --dirty" % (gitdir,)
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE)
|
process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE)
|
||||||
output = process.communicate()[0]
|
output = process.communicate()[0]
|
||||||
|
|
Loading…
Reference in New Issue