Skip to content

Commit

Permalink
Merge pull request #153 from rao-aneesh/patch-2
Browse files Browse the repository at this point in the history
Change to u_val
  • Loading branch information
akarneliuk authored Apr 3, 2024
2 parents 21f6285 + 5ae6be0 commit ca18567
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pygnmi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,8 @@ def construct_update_message(user_list: list, encoding: str) -> list:
for ue in user_list:
if isinstance(ue, tuple):
u_path = gnmi_path_generator(ue[0])
u_val = ue[1].encode("utf-8") if isinstance(ue[1], str) else json.dumps(ue[1]).encode("utf-8")
u_val = json.dumps(ue[1]).encode("utf-8")
u_ascii_val = str(ue[1]).encode("utf-8")
encoding = encoding.lower() # Normalize to lower case
if encoding == "json":
result.append(Update(path=u_path, val=TypedValue(json_val=u_val)))
Expand All @@ -1444,7 +1445,7 @@ def construct_update_message(user_list: list, encoding: str) -> list:
elif encoding == "proto":
result.append(Update(path=u_path, val=TypedValue(proto_bytes=u_val)))
elif encoding == "ascii":
result.append(Update(path=u_path, val=TypedValue(ascii_val=u_val)))
result.append(Update(path=u_path, val=TypedValue(ascii_val=u_ascii_val)))
elif encoding == "json_ietf":
result.append(Update(path=u_path, val=TypedValue(json_ietf_val=u_val)))
else:
Expand Down

0 comments on commit ca18567

Please sign in to comment.