Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Corrected parsing for alternate battery format
Browse files Browse the repository at this point in the history
  • Loading branch information
jheddings committed Nov 26, 2016
1 parent 1363f1e commit cfffaed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Contents/Server Plugin/pmset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _parsePowerInfo(rawOutput):

################################################################################
def _parseBatteryLine(line):
match = re.search(r'-([^\s]+)\s+(\d+)%;\s*([^;]+)', line.strip())
match = re.search(r'-([^\s]+).*\b(\d+)%;\s*([^;]+)', line.strip())
if not match: return None

return BatteryInfo(
Expand Down
10 changes: 10 additions & 0 deletions Contents/Server Plugin/test_cases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ Currently drawing from 'UPS Power'
Currently drawing from 'AC Power'
-UPS CP600 100%; charging
</TestCase>

<TestCase id="11" name="w/ ID: On Battery">
Now drawing from 'Battery Power'
-InternalBattery-0 (id=4587619) 40%; discharging; 3:03 remaining present: true
</TestCase>

<TestCase id="12" name="w/ ID: Charging">
Now drawing from 'AC Power'
-InternalBattery-0 (id=4587619) 39%; AC attached; not charging present: true
</TestCase>
</TestCases>

0 comments on commit cfffaed

Please sign in to comment.