revert readprops change

This commit is contained in:
Thomas Göttgens 2023-02-02 11:32:00 +01:00
parent e9a55fc296
commit 945fd7a05c

View File

@ -1,7 +1,9 @@
import configparser
import subprocess import subprocess
import sys import configparser
import traceback import traceback
import sys
def readProps(prefsLoc): def readProps(prefsLoc):
@ -9,36 +11,27 @@ def readProps(prefsLoc):
config = configparser.RawConfigParser() config = configparser.RawConfigParser()
config.read(prefsLoc) config.read(prefsLoc)
version = dict(config.items("VERSION")) version = dict(config.items('VERSION'))
verObj = dict( verObj = dict(short = "{}.{}.{}".format(version["major"], version["minor"], version["build"]),
short="{}.{}.{}".format(version["major"], version["minor"], version["build"]), long = "unset")
long="unset",
)
# Try to find current build SHA if if the workspace is clean. This could fail if git is not installed # Try to find current build SHA if if the workspace is clean. This could fail if git is not installed
try: try:
sha = ( sha = subprocess.check_output(
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) ['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip()
.decode("utf-8") isDirty = subprocess.check_output(
.strip() ['git', 'diff', 'HEAD']).decode("utf-8").strip()
)
isDirty = (
subprocess.check_output(["git", "diff", "HEAD"]).decode("utf-8").strip()
)
suffix = sha suffix = sha
# if isDirty: if isDirty:
# # short for 'dirty', we want to keep our verstrings source for protobuf reasons # short for 'dirty', we want to keep our verstrings source for protobuf reasons
# suffix = sha + "-d" suffix = sha + "-d"
verObj["long"] = "{}.{}.{}.{}".format( verObj['long'] = "{}.{}.{}.{}".format(
version["major"], version["minor"], version["build"], suffix version["major"], version["minor"], version["build"], suffix)
)
except: except:
# print("Unexpected error:", sys.exc_info()[0]) # print("Unexpected error:", sys.exc_info()[0])
# traceback.print_exc() # traceback.print_exc()
verObj["long"] = verObj["short"] verObj['long'] = verObj['short']
# print("firmware version " + verStr) # print("firmware version " + verStr)
return verObj return verObj
# print("path is" + ','.join(sys.path)) # print("path is" + ','.join(sys.path))