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

254 lines
5.7 KiB
Markdown
Raw Normal View History

[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.acpi"></a>
2021-03-16 11:45:56 -07:00
# jc.parsers.acpi
2022-01-25 17:07:47 -08:00
2022-03-04 13:27:39 -08:00
jc - JSON Convert `acpi` command output parser
2021-03-16 11:45:56 -07:00
Usage (cli):
2022-01-25 18:03:34 -08:00
$ acpi -V | jc --acpi
2021-03-16 11:45:56 -07:00
2022-01-25 18:03:34 -08:00
or
2021-03-16 11:45:56 -07:00
2022-01-25 18:03:34 -08:00
$ jc acpi -V
2021-03-16 11:45:56 -07:00
Usage (module):
2022-01-25 18:03:34 -08:00
import jc
result = jc.parse('acpi', acpi_command_output)
2022-01-18 14:18:12 -08:00
Schema:
2022-01-25 18:03:34 -08:00
[
{
"type": string,
"id": integer,
"state": string,
"charge_percent": integer,
"until_charged": string,
"until_charged_hours": integer,
"until_charged_minuts": integer,
"until_charged_seconds": integer,
"until_charged_total_seconds": integer,
"charge_remaining": string,
"charge_remaining_hours": integer,
"charge_remaining_minutes": integer,
"charge_remaining_seconds": integer,
"charge_remaining_total_seconds": integer,
"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
]
}
]
2022-01-25 18:03:34 -08:00
Examples:
2021-03-16 11:45:56 -07:00
2022-01-25 18:03:34 -08:00
$ 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,
"until_charged_hours": 0,
"until_charged_minutes": 29,
"until_charged_seconds": 20,
"until_charged_total_seconds": 1760
},
{
"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"
]
}
]
2021-03-16 11:45:56 -07:00
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.acpi.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-01-25 17:07:47 -08:00
2021-03-16 11:45:56 -07:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
2021-03-16 11:45:56 -07:00
```
Main text parsing function
2022-01-25 18:03:34 -08:00
Parameters:
2021-03-16 11:45:56 -07:00
2022-01-25 18:03:34 -08:00
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2021-03-16 11:45:56 -07:00
2022-01-25 18:03:34 -08:00
Returns:
2021-03-16 11:45:56 -07:00
2022-01-25 18:03:34 -08:00
List of Dictionaries. Raw or processed structured data.
2021-03-16 11:45:56 -07:00
2022-01-25 19:18:54 -08:00
### Parser Information
Compatibility: linux
2022-07-16 20:52:19 -07:00
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)