2021-04-09 10:36:42 -07:00
|
|
|
[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
|
|
|
|
2021-03-16 11:45:56 -07:00
|
|
|
jc - JSON CLI output utility `acpi` command output parser
|
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
$ acpi -V | jc --acpi
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
or
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
$ jc acpi -V
|
2021-03-16 11:45:56 -07:00
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
import jc
|
|
|
|
result = jc.parse('acpi', acpi_command_output)
|
2022-01-18 14:18:12 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
or
|
2022-01-18 14:18:12 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
import jc.parsers.acpi
|
|
|
|
result = jc.parsers.acpi.parse(acpi_command_output)
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2021-04-08 11:24:02 -07:00
|
|
|
Schema:
|
|
|
|
|
2022-01-25 17:07:47 -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
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2021-04-08 11:24:02 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Examples**:
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -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.info"></a>
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
## info Objects
|
2021-03-16 11:45:56 -07:00
|
|
|
|
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
class info()
|
2021-03-16 11:45:56 -07:00
|
|
|
```
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2021-04-08 11:24:02 -07:00
|
|
|
Provides parser metadata (version, author, etc.)
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.acpi.parse"></a>
|
|
|
|
|
|
|
|
#### parse
|
|
|
|
|
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 17:07:47 -08:00
|
|
|
**Arguments**:
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -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 17:07:47 -08:00
|
|
|
**Returns**:
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
List of Dictionaries. Raw or processed structured data.
|
2021-03-16 11:45:56 -07:00
|
|
|
|
2021-04-09 10:36:42 -07:00
|
|
|
## Parser Information
|
|
|
|
Compatibility: linux
|
|
|
|
|
2021-12-01 16:12:51 -08:00
|
|
|
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|