1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00

fix for full charge batter case. Clean up battery object logic

This commit is contained in:
Kelly Brazil
2021-03-12 08:45:32 -08:00
parent 7378d5dce4
commit 1f7aafd041
3 changed files with 19 additions and 9 deletions

View File

@ -358,23 +358,20 @@ def parse(data, raw=False, quiet=False):
if obj_type == 'Battery':
output_line['type'] = obj_type
output_line['id'] = obj_id
if 'Charging' in line:
if 'Charging' in line or 'Discharging' in line or 'Full' in line:
output_line['state'] = line.split()[2][:-1]
output_line['charge_percent'] = line.split()[3][:-2]
output_line['charge_percent'] = line.split()[3].rstrip('%,')
if 'rate information unavailable' not in line:
if 'Charging' in line:
output_line['until_charged'] = line.split()[4]
if 'Discharging' in line:
output_line['charge_remaining'] = line.split()[4]
if 'design capacity' in line:
output_line['design_capacity_mah'] = line.split()[4]
output_line['last_full_capacity'] = line.split()[9]
output_line['last_full_capacity_percent'] = line.split()[-1][:-1]
if 'Discharging' in line:
output_line['state'] = line.split()[2][:-1]
output_line['charge_percent'] = line.split()[3][:-2]
if 'rate information unavailable' not in line:
output_line['charge_remaining'] = line.split()[4]
last_line_state = line_state
continue

View File

@ -3,6 +3,7 @@ Battery 0: design capacity 2110 mAh, last full capacity 2271 mAh = 100%
Battery 1: Discharging, 98%, 01:43:14 remaining
Battery 1: design capacity 4400 mAh, last full capacity 3013 mAh = 68%
Battery 2: Discharging, 0%, rate information unavailable
Battery 3: Full, 100%
Adapter 0: on-line
Adapter 1: off-line
Thermal 0: ok, 46.0 degrees C

12
tests/fixtures/generic/acpi-V4.out vendored Normal file
View File

@ -0,0 +1,12 @@
Battery 0: Full, 100%
Battery 0: design capacity 1969 mAh, last full capacity 2118 mAh = 100%
Adapter 0: on-line
Thermal 0: ok, 45.0 degrees C
Thermal 0: trip point 0 switches to mode critical at temperature 127.0 degrees C
Thermal 0: trip point 1 switches to mode hot at temperature 127.0 degrees C
Cooling 0: Processor 0 of 10
Cooling 1: Processor 0 of 10
Cooling 2: x86_pkg_temp no state information available
Cooling 3: Processor 0 of 10
Cooling 4: intel_powerclamp no state information available
Cooling 5: Processor 0 of 10