feat: add upsc parser for NUT (Network UPS Tools) output - #710
Open
AYUSHPALLAV1 wants to merge 1 commit into
Open
feat: add upsc parser for NUT (Network UPS Tools) output#710AYUSHPALLAV1 wants to merge 1 commit into
AYUSHPALLAV1 wants to merge 1 commit into
Conversation
Adds a new parser for the upsc command output from Network UPS Tools (NUT). The parser converts the key: value output format to a list of dictionaries, with numeric values automatically converted to int or float types in processed output. Fixes kellyjonbrazil#556 Changes: - Add jc/parsers/upsc.py with full parser implementation - Register 'upsc' in jc/lib.py parser list - Add tests/test_upsc.py unit test file - Add test fixtures: upsc--cyberpower.out and upsc--cyberpower.json
Owner
|
Thanks for the contribution! I'm not sure if this parser is needed as the functionality exists with the key/value ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new parser for the
upsccommand from Network UPS Tools (NUT).Closes #556
What does this parser do?
The
upsccommand queries a UPS device and returnskey: valuepairs. This parser converts that output to a list of dictionaries with automatic type conversion for numeric values.Input Format
battery.charge: 100 battery.voltage: 24.0 ups.status: OL ups.test.result: No test initiatedOutput (processed)
json [ {"name": "battery.charge", "value": 100}, {"name": "battery.voltage", "value": 24.0}, {"name": "ups.status", "value": "OL"}, {"name": "ups.test.result", "value": "No test initiated"} ]Changes
jc/parsers/upsc.py- New parser implementationjc/lib.py- Registeredupscin the parser listtests/test_upsc.py- Unit teststests/fixtures/generic/upsc--cyberpower.out- Sample command output fixturetests/fixtures/generic/upsc--cyberpower.json- Expected JSON output fixtureCompatibility