-
Notifications
You must be signed in to change notification settings - Fork 54
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
Implements #34: Split into Client and CLI classes #41
Conversation
I understand this is a big change, maybe #40 is the safer choice for now :) |
Thanks for starting this! Splitting the clients into separate modules looks fine but I am not sure about the I am also not sure about the CLI modules and classes. There is a lot of code duplication there and I feel that we should be able merge all of those after some refactoring. I suggest to keep this stuff in What do you think? |
Just wanted to add my two cents since I added the v107 part some days ago:
I think I'll make a quick draft about my intital intention of this baseclass. |
Just a quick draft is here #42, which won't work (except for 1.0.7), just to have an idea of the base class |
ok I think that this is due to something not really installed with "python3 setup.py install", it can't find the cli-files. Ok enough for today ... |
@rgerganov, moved the clients out of the package and moved the CLIs in @Cyber1000, yeah I figured that was the idea with the |
It makes sense to me to have a CLI class on top of the client. The client classes shouldn't be worried about printing and formatting data, just returning it. I agree the CLIs are very similar right now and can be refactored more though |
👍
I didn't know this before (python is not my main-language), if we keep this maybe a own contribute-section in the README would be nice with hints how to install (for example I use vscode and black seems to integrate nicely with that - https://medium.com/@marcobelo/setting-up-python-black-on-visual-studio-code-5318eba4cd00 ). But that's up to the repo-owner @rgerganov |
My purifier uses 0.2.1 and it works. |
if debug: | ||
self.coapthon_logger.setLevel("DEBUG") | ||
status = self._get() | ||
status = self._client.get_values(debug) |
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 should be get_status
instead of get_values
. Will commit your PR as is and will fix it in a later patch.
Thanks @GeorgeSG, I have merged your work.
It appears that firmwares with the same version could be using different communication protocols. I am going to replace the
|
Notice
I have an old purifier that uses
HTTPAirClient
. I've tested that and it looks like it's working. I have no way to test the other clients / CLIs. It would be awesome if someone else can try this and verify that it works :)Summary
Initial version of splitting pyairctrl into Client and CLI Classes.
Clients:
HTTPAirClient
CoAPAirClient
Version107Client
CLIs:
HTTPAirCli
CoAPAirCli
Version107Cli
Basically, CLIs act as a wrapper for each client and add printing of responses (dump_status, etc).
airctrl
now uses CLI classes.Misc changes
.gitignore
because I usedvenv
to develop this.pylintrc
black
. Let me know if you prefer some other formatting.Todo and next steps
CloudClient
fromcloudctrl
as a clientstatus_transformer
in other CLIs? Currently used in v107 only~/.pyairctrl
file logic. It's in the HTTP Client now. Maybe it should be optional or moved to the CLI? Not sure pure clients need this.In general, I think this is a good first step to split up the codebase, but definitely could use more work.