Skip to content

feat: add upsc parser for NUT (Network UPS Tools) output - #710

Open
AYUSHPALLAV1 wants to merge 1 commit into
kellyjonbrazil:masterfrom
AYUSHPALLAV1:feature/upsc-parser
Open

feat: add upsc parser for NUT (Network UPS Tools) output#710
AYUSHPALLAV1 wants to merge 1 commit into
kellyjonbrazil:masterfrom
AYUSHPALLAV1:feature/upsc-parser

Conversation

@AYUSHPALLAV1

Copy link
Copy Markdown

Summary

Adds a new parser for the upsc command from Network UPS Tools (NUT).

Closes #556

What does this parser do?

The upsc command queries a UPS device and returns key: value pairs. 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 initiated

Output (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 implementation
  • jc/lib.py - Registered upsc in the parser list
  • tests/test_upsc.py - Unit tests
  • tests/fixtures/generic/upsc--cyberpower.out - Sample command output fixture
  • tests/fixtures/generic/upsc--cyberpower.json - Expected JSON output fixture

Compatibility

  • Linux, Darwin, FreeBSD (platforms where NUT/upsc runs)

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
@kellyjonbrazil

Copy link
Copy Markdown
Owner

Thanks for the contribution! I'm not sure if this parser is needed as the functionality exists with the key/value (--kv) parser.

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.

New Parser - NUT-upsc command

2 participants