bin: remove unused imports from readprops.py (#3907)

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Jorropo 2024-08-20 13:38:16 +02:00 committed by GitHub
parent 2472c7cdc7
commit 2043ad3bd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,9 +1,5 @@
import subprocess
import configparser import configparser
import traceback import subprocess
import sys
def readProps(prefsLoc): def readProps(prefsLoc):
@ -11,27 +7,36 @@ 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(short = "{}.{}.{}".format(version["major"], version["minor"], version["build"]), verObj = dict(
long = "unset") short="{}.{}.{}".format(version["major"], version["minor"], version["build"]),
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 = subprocess.check_output( sha = (
['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip() subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
isDirty = subprocess.check_output( .decode("utf-8")
['git', 'diff', 'HEAD']).decode("utf-8").strip() .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))