mirror of
https://github.com/powerline/powerline.git
synced 2025-07-24 06:15:41 +02:00
Merge pull request #888 from ZyX-I/run_cmd-unicode
Decode stdout in shell.run_cmd
This commit is contained in:
commit
b145b7064f
@ -1,6 +1,7 @@
|
|||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
|
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
from locale import getlocale, getdefaultlocale, LC_MESSAGES
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(pl, cmd, stdin=None):
|
def run_cmd(pl, cmd, stdin=None):
|
||||||
@ -11,6 +12,8 @@ def run_cmd(pl, cmd, stdin=None):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
stdout, err = p.communicate(stdin)
|
stdout, err = p.communicate(stdin)
|
||||||
|
encoding = getlocale(LC_MESSAGES)[1] or getdefaultlocale()[1] or 'utf-8'
|
||||||
|
stdout = stdout.decode(encoding)
|
||||||
return stdout.strip()
|
return stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user