Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to unicode in macosx battery.py #410

Merged
merged 1 commit into from
Aug 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions plyer/platforms/macosx/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ def _get_state(self):
return status

is_charging = max_capacity = current_capacity = None
for line in output.splitlines():
if b'IsCharging' in line:
is_charging = line.rpartition(b'=')[-1].strip()
if b'MaxCapacity' in line:
max_capacity = float(line.rpartition(b'=')[-1].strip())
if b'CurrentCapacity' in line:
current_capacity = float(line.rpartition(b'=')[-1].strip())
for line in output.decode('utf-8').splitlines():
if 'IsCharging' in line:
is_charging = line.rpartition('=')[-1].strip()
if 'MaxCapacity' in line:
max_capacity = float(line.rpartition('=')[-1].strip())
if 'CurrentCapacity' in line:
current_capacity = float(line.rpartition('=')[-1].strip())

if is_charging:
status['isCharging'] = is_charging == b"Yes"
status['isCharging'] = is_charging == "Yes"

if current_capacity and max_capacity:
status['percentage'] = 100.0 * current_capacity / max_capacity
Expand Down