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

Use environ to change LANG to 'C' while calling shell processes #119

Merged
merged 1 commit into from
Mar 10, 2015
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions plyer/platforms/linux/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
from plyer.facades import Battery
from plyer.utils import whereis_exe

from os import environ


class LinuxBattery(Battery):
def _get_state(self):
old_lang = environ.get('LANG')
environ['LANG'] = 'C'

status = {"isCharging": None, "percentage": None}

# We are supporting only one battery now
Expand All @@ -13,6 +18,8 @@ def _get_state(self):
stdout=PIPE)
output = upower_process.communicate()[0]

environ['LANG'] = old_lang

if not output:
return status

Expand Down
7 changes: 7 additions & 0 deletions plyer/platforms/macosx/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
from plyer.facades import Battery
from plyer.utils import whereis_exe

from os import environ


class OSXBattery(Battery):
def _get_state(self):
old_lang = environ.get('LANG')
environ['LANG'] = 'C'

status = {"isCharging": None, "percentage": None}

ioreg_process = Popen(["ioreg", "-rc", "AppleSmartBattery"],
stdout=PIPE)
output = ioreg_process.communicate()[0]

environ['LANG'] = old_lang

if not output:
return status

Expand Down
7 changes: 7 additions & 0 deletions plyer/platforms/macosx/uniqueid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
from plyer.facades import UniqueID
from plyer.utils import whereis_exe

from os import environ


class OSXUniqueID(UniqueID):
def _get_uid(self):
old_lang = environ.get('LANG')
environ['LANG'] = 'C'

ioreg_process = Popen(["ioreg", "-l"], stdout=PIPE)
grep_process = Popen(["grep", "IOPlatformSerialNumber"],
stdin=ioreg_process.stdout, stdout=PIPE)
ioreg_process.stdout.close()
output = grep_process.communicate()[0]

environ['LANG'] = old_lang

if output:
return output.split()[3][1:-1]
else:
Expand Down