fix: wrong dir when getting snapshot version
This commit is contained in:
parent
8870667064
commit
23dc9d2460
24
util.py
24
util.py
@ -27,6 +27,8 @@ def solve_filepath(path):
|
|||||||
|
|
||||||
if path[0] == '/':
|
if path[0] == '/':
|
||||||
return path
|
return path
|
||||||
|
elif os.path.exists(path):
|
||||||
|
return path
|
||||||
else:
|
else:
|
||||||
mydir = os.path.dirname(os.path.realpath(__file__))
|
mydir = os.path.dirname(os.path.realpath(__file__))
|
||||||
return mydir + '/' + path
|
return mydir + '/' + path
|
||||||
@ -458,22 +460,24 @@ def set_logging_formatter(handler: logging.Handler, logging_level):
|
|||||||
|
|
||||||
def get_snapshot_version():
|
def get_snapshot_version():
|
||||||
import subprocess
|
import subprocess
|
||||||
|
wd = os.getcwd()
|
||||||
root_dir = os.path.dirname(__file__)
|
root_dir = os.path.dirname(__file__)
|
||||||
|
os.chdir(root_dir)
|
||||||
|
|
||||||
|
ver = "unknown"
|
||||||
if os.path.exists(os.path.join(root_dir, ".git")):
|
if os.path.exists(os.path.join(root_dir, ".git")):
|
||||||
try:
|
try:
|
||||||
ret = subprocess.check_output(["git", "describe"]).strip()
|
ret = subprocess.check_output(["git", "describe"]).strip()
|
||||||
return ret.decode("utf-8")
|
ver = ret.decode("utf-8")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
try:
|
||||||
|
with open(os.path.join(root_dir, ".git/refs/heads/master")) as f:
|
||||||
|
ver = "g" + f.read()[:7]
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
os.chdir(wd)
|
||||||
with open(os.path.join(root_dir,".git/refs/heads/master")) as f:
|
return ver
|
||||||
ret = "g" + f.read()[:7]
|
|
||||||
return ret
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return "unknown"
|
|
||||||
|
|
||||||
|
|
||||||
class LoggerIOWrapper(io.TextIOWrapper):
|
class LoggerIOWrapper(io.TextIOWrapper):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user