Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add support for UBC1303BA00 and other modems with JSON-formatted lists #24
Add support for UBC1303BA00 and other modems with JSON-formatted lists #24
Changes from 6 commits
4c0801a
2423b8d
584cdc1
c6a16f2
d60ac9c
65b8088
671563b
51172aa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to do anything by itself, except holding a username/password. Later on, the flow is changed solely for this
Authenticator
. I am for using as much as possible from other libraries, but I am also for consistency in the software and flow. I see you "forgot" to change the_post()
method (probably don't need it in your case.) When somebody else wants to add support for their router, s/he will have to figure out what is happening/why it is done this way.One option is to make our own
DigestAuthenticator
, but with its own logic and not relying onrequests
. Sure, this defeats the re-use of therequests
'HTTPDigestAuth
, but simplifies the the software in other parts.Or maybe the current Authenticators can be changed such that these can be passed to
requests.get(auth=..)
/requests.post(auth=..)
Or perhaps there is another option, one I haven't thought of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I didn't need the POST method so I left it untouched. I can change that for sure.
I also would like the code flow to be consistent. However, reinventing the wheel here would just feel stupider. According to all the debug prints in the rest of the
_get()
method it seems like it is rather cumbersome. On top of that, I don't really see the point in not relying inrequests
; it is used later on in both_get()
and_post()
anyway. If I wrote the code from scratch, I would've mayberequests
instead of creating our own (and if our own is needed, create a child class of anrequests
authenticator)Ubee
class, so that it can be dynamically used as for example inside the_get()
as follows:response = requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, auth=_self.authenticator(self.username, self.password))
whereself.authenticator
was a (derivative of)requests Authenticator
class.So yes, I would've preferred the Authenticators of
pyubee
to be compatible with requests. It would remove the reinvention of the wheel I was talking before. After the change, the whole GET or POST methods would be one-liners :)I will take a closer look at the comments tomorrow. Thanks for the review. This is just my opinion on this one comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are entirely right that it is better to use the tools
requests
provides, thank you for showing this. I guess this was added at some point and others just continued building on the things that were already there.Though some
Authenticator
s do sneak in their ownGET
s/POST
s, necessary for some models. Not sure how to handle this, but probably possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this need the alternate flow for the new Authenticator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik this is handled by the one-liner
requests.get(...)
. I'll leave this open though, not 100% sure if some manual work is needed here.