semi-experimentally, add fallback code for message_to_json, allowing older protobuf library versions

This commit is contained in:
Ian McEwen committed 2024-11-15 11:47:17 -07:00
1 parent fb88ee114c
commit 426795fccd
3 files changed
+728 -766

No files matched your search

+4 -1
View File
@@ -675,5 +675,8 @@ def check_if_newer_version() -> Optional[str]:
def message_to_json(message: Message, multiline: bool=False) -> str:
"""Return protobuf message as JSON. Always print all fields, even when not present in data."""
json = MessageToJson(message, always_print_fields_with_no_presence=True)
try:
json = MessageToJson(message, always_print_fields_with_no_presence=True)
except TypeError:
json = MessageToJson(message, including_default_value_fields=True)
return stripnl(json) if not multiline else json
Generated
+722 -763
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -9,7 +9,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.9,<3.14" # 3.9 is needed for pandas, bleak requires <3.14
pyserial = "^3.5"
protobuf = ">=5.26.0"
protobuf = ">=4.21.12"
dotmap = "^1.3.30"
pexpect = "^4.9.0"
pyqrcode = "^1.2.1"
@@ -37,7 +37,7 @@ autopep8 = "^2.1.0"
pylint = "^3.2.3"
pyinstaller = "^6.8.0"
mypy = "^1.10.0"
mypy-protobuf = "^3.6.0"
mypy-protobuf = { version = "^3.3.0", optional = true }
types-protobuf = "^5.26.0.20240422"
types-tabulate = "^0.9.0.20240106"
types-requests = "^2.31.0.20240406"