Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to u_val #144

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pygnmi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ 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 = json.dumps(ue[1]).encode("utf-8")
u_val = ue[1].encode("utf-8") if isinstance(ue[1], str) else json.dumps(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 @@ -1346,7 +1346,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[1:-1])))
result.append(Update(path=u_path, val=TypedValue(ascii_val=u_val)))
elif encoding == "json_ietf":
result.append(Update(path=u_path, val=TypedValue(json_ietf_val=u_val)))
else:
Expand Down
Loading