meshtastic-firmware/bin/readprops.py

38 wiersze
1.2 KiB
Python
Czysty Zwykły widok Historia

2021-04-16 03:04:03 +00:00
import subprocess
import configparser
import traceback
import sys
def readProps(prefsLoc):
"""Read the version of our project as a string"""
config = configparser.RawConfigParser()
config.read(prefsLoc)
version = dict(config.items('VERSION'))
2021-05-03 01:50:06 +00:00
verObj = dict(short = "{}.{}.{}".format(version["major"], version["minor"], version["build"]),
long = "unset")
2021-04-16 03:04:03 +00:00
# Try to find current build SHA if if the workspace is clean. This could fail if git is not installed
try:
sha = subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip()
isDirty = subprocess.check_output(
['git', 'diff', 'HEAD']).decode("utf-8").strip()
suffix = sha
2023-01-28 20:50:07 +00:00
# if isDirty:
# # short for 'dirty', we want to keep our verstrings source for protobuf reasons
# suffix = sha + "-d"
2021-05-03 01:50:06 +00:00
verObj['long'] = "{}.{}.{}.{}".format(
2021-04-16 03:04:03 +00:00
version["major"], version["minor"], version["build"], suffix)
except:
# print("Unexpected error:", sys.exc_info()[0])
# traceback.print_exc()
2021-05-03 01:50:06 +00:00
verObj['long'] = verObj['short']
2021-04-16 03:04:03 +00:00
2022-07-29 22:58:42 +00:00
# print("firmware version " + verStr)
2021-05-03 01:50:06 +00:00
return verObj
2021-04-16 03:04:03 +00:00
# print("path is" + ','.join(sys.path))