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

Refactoring of client and cli #88

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

Cyber1000
Copy link
Contributor

Preparation for using client-classes with something more server-centric (rest-service, mqtt, ...)

Tasks

  • Merge Use one base class for plain_coap and coap #86 before
  • check set_values (with and without wifi) of http-protocol (2 TODOs in here - I don't know exactly the output - think it may be status: success, like in other implementations)

General information

  • cleaned up client and cli classes
  • client output changed (outputting raw and transformed values), cli output doesn't change (besides of smaller debug output changes)
  • Every commit is a single change (more or less) to make it easier to review

Changes in clients

  • moved CoAPAirClientBase to base_client.py
  • AirClientBase is now a base for all clients (http, coap, plain_coap) and is for setting some base-values like logger, adds methods for getting the json in shape
    • this base-class takes a parameter debug, thus "debug" is not needed anymore in get and set-methods (was inconsistent between different protocols)
  • Changed json in clients:
    • STATUS_TRANSFORMER is now used directly in client-classes to transform raw-values
    • description, name, subset, raw, value is added to json coming from the device
    • coap/plain_coap: filter, firmware always returned the full dataset (was reduced on client-side) - now client side only returns relevant data
  • Runtime (in h) was modulo 24, so cut off afer one day
  • removed get_status in favor of get_information (includes firmware and filters as well)
  • changed ssdp to get_devices (if get_devices not possible - coap, plain-coap - an exception is thrown, which is caught by cli)
  • moved set_wifi to set_values and added subset as switch

Changes in cli

  • output in debug mode was changed to be json-compliant - see JSON output #78
  • a new CLI_FORMAT is used here instead of STATUS_TRANSFORMER, which outputs things with user-friendly messages like "Pre-filter and Wick: clean in 5 hours"
  • if you add "--debug" in addition to --filters, --firmware, --wifi you also get debug output
  • after set_values is called also get_values is called
  • simplified creation of clients by introducing class ClientFactory

example output of new client classes (see also Examples.md)

    "mode": {
        "name": "Mode",
        "raw": "A",
        "value": "allergen",
        "subsets": [
            "status"
        ],
        "rawDescription": null,
        "valueDescription": null
    },

- moved debug-param to ctor, get/set-methods don't take it anymore
- changed json output of client-classes
- added CLI_FORMAT and using it on cli-side
- coap/plain_coap: filter, firmware always returned the full dataset
- extending --debug for wifi, filters, firmware
(includes firmware and filters as well)
-  added subset as switch to set_values
- added/cleaned up exceptions
@Cyber1000
Copy link
Contributor Author

Since tests are still running without substantial changes (just refactoring issues), I'm assuming this PR doesn't break anything, thought I'm uncertain if #86 breaks connection with plain_coap.

@Cyber1000
Copy link
Contributor Author

Cyber1000 commented May 14, 2021

- print not needed in tests
- enhanced formatting of examples.md
@wldevries
Copy link

Does anything need to happen before this can be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants