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

[WIP] Make restconf_get work with NX-OS #307

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
5 changes: 3 additions & 2 deletions plugins/httpapi/restconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ def send_request(self, data, **message_kwargs):

def handle_response(response, response_data):
try:
response_data = json.loads(response_data.read())
res = response_data.read().strip()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
res = response_data.read().strip()
res = response_data.read().strip()
try:

(It won't let me remove the try above, but you get the idea)

The reason it's split into response and response_data is that the latter is a buffer containing the read-once data from the former, so you should be able to response_data.seek(0) and get the same result. But this is just fine, too.

response_data = json.loads(res)
except ValueError:
response_data = response_data.read()
response_data = res

if isinstance(response, HTTPError):
if response_data:
Expand Down