1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

version bump to v1.15.0. Add acpi docs

This commit is contained in:
Kelly Brazil
2021-03-16 11:45:56 -07:00
parent 46962ff02a
commit bd425f2493
6 changed files with 321 additions and 2 deletions

View File

@ -1,5 +1,9 @@
jc changelog jc changelog
20210316 v1.15.0
- Add acpi parser tested on linux
- Add upower parser tested on linux
20210305 v1.14.4 20210305 v1.14.4
- Packaging fix only for binaries and RPMs hosted on https://github.com/kellyjonbrazil/jc-packaging. - Packaging fix only for binaries and RPMs hosted on https://github.com/kellyjonbrazil/jc-packaging.
Packages from PyPi and OS repositories are not affected. This fixes an issue that kept the YAML Packages from PyPi and OS repositories are not affected. This fixes an issue that kept the YAML

View File

@ -1,4 +1,62 @@
## JC Examples ## JC Examples
### acpi
```bash
acpi -V | jc --acpi -p # or: jc -p acpi -V
```
```json
[
{
"type": "Battery",
"id": 0,
"state": "Charging",
"charge_percent": 71,
"until_charged": "00:29:20",
"design_capacity_mah": 2110,
"last_full_capacity": 2271,
"last_full_capacity_percent": 100
},
{
"type": "Adapter",
"id": 0,
"on-line": true
},
{
"type": "Thermal",
"id": 0,
"mode": "ok",
"temperature": 46.0,
"temperature_unit": "C",
"trip_points": [
{
"id": 0,
"switches_to_mode": "critical",
"temperature": 127.0,
"temperature_unit": "C"
},
{
"id": 1,
"switches_to_mode": "hot",
"temperature": 127.0,
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": 0,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 1,
"messages": [
"Processor 0 of 10"
]
}
]
```
### airport -I ### airport -I
```bash ```bash
airport -I | jc --airport -p # or: jc -p airport -I airport -I | jc --airport -p # or: jc -p airport -I

View File

@ -5,6 +5,7 @@
cd jc cd jc
pydocmd simple jc+ > ../docs/readme.md pydocmd simple jc+ > ../docs/readme.md
pydocmd simple utils+ > ../docs/utils.md pydocmd simple utils+ > ../docs/utils.md
pydocmd simple jc.parsers.acpi+ > ../docs/parsers/acpi.md
pydocmd simple jc.parsers.airport+ > ../docs/parsers/airport.md pydocmd simple jc.parsers.airport+ > ../docs/parsers/airport.md
pydocmd simple jc.parsers.airport_s+ > ../docs/parsers/airport_s.md pydocmd simple jc.parsers.airport_s+ > ../docs/parsers/airport_s.md
pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md

256
docs/parsers/acpi.md Normal file
View File

@ -0,0 +1,256 @@
# jc.parsers.acpi
jc - JSON CLI output utility `acpi` command output parser
Usage (cli):
$ acpi -V | jc --acpi
or
$ jc acpi -V
Usage (module):
import jc.parsers.acpi
result = jc.parsers.acpi.parse(acpi_command_output)
Compatibility:
'linux'
Examples:
$ acpi -V | jc --acpi -p
[
{
"type": "Battery",
"id": 0,
"state": "Charging",
"charge_percent": 71,
"until_charged": "00:29:20",
"design_capacity_mah": 2110,
"last_full_capacity": 2271,
"last_full_capacity_percent": 100
},
{
"type": "Adapter",
"id": 0,
"on-line": true
},
{
"type": "Thermal",
"id": 0,
"mode": "ok",
"temperature": 46.0,
"temperature_unit": "C",
"trip_points": [
{
"id": 0,
"switches_to_mode": "critical",
"temperature": 127.0,
"temperature_unit": "C"
},
{
"id": 1,
"switches_to_mode": "hot",
"temperature": 127.0,
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": 0,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 1,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 2,
"messages": [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": 3,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 4,
"messages": [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": 5,
"messages": [
"Processor 0 of 10"
]
}
]
$ acpi -V | jc --acpi -p -r
[
{
"type": "Battery",
"id": "0",
"state": "Charging",
"charge_percent": "71",
"until_charged": "00:29:20",
"design_capacity_mah": "2110",
"last_full_capacity": "2271",
"last_full_capacity_percent": "100"
},
{
"type": "Adapter",
"id": "0",
"on-line": true
},
{
"type": "Thermal",
"id": "0",
"mode": "ok",
"temperature": "46.0",
"temperature_unit": "C",
"trip_points": [
{
"id": "0",
"switches_to_mode": "critical",
"temperature": "127.0",
"temperature_unit": "C"
},
{
"id": "1",
"switches_to_mode": "hot",
"temperature": "127.0",
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": "0",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "1",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "2",
"messages": [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": "3",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "4",
"messages": [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": "5",
"messages": [
"Processor 0 of 10"
]
}
]
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"type": string,
"id": integer,
"state": string,
"charge_percent": integer,
"until_charged": string,
"charge_remaining" string,
"design_capacity_mah": integer,
"last_full_capacity": integer,
"last_full_capacity_percent": integer,
"on-line": boolean,
"mode": string,
"temperature": float,
"temperature_unit": string,
"trip_points": [
{
"id": integer,
"switches_to_mode": string,
"temperature": float,
"temperature_unit": string
}
],
"messages": [
string
]
}
]
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.

View File

@ -21,7 +21,7 @@ import jc.appdirs as appdirs
class info(): class info():
version = '1.14.5' version = '1.15.0'
description = 'JSON CLI output utility' description = 'JSON CLI output utility'
author = 'Kelly Brazil' author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com' author_email = 'kellyjonbrazil@gmail.com'

View File

@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
setuptools.setup( setuptools.setup(
name='jc', name='jc',
version='1.14.4', version='1.15.0',
author='Kelly Brazil', author='Kelly Brazil',
author_email='kellyjonbrazil@gmail.com', author_email='kellyjonbrazil@gmail.com',
description='Converts the output of popular command-line tools and file-types to JSON.', description='Converts the output of popular command-line tools and file-types to JSON.',