compatiable for git-bash on windows

This commit is contained in:
six 2019-01-21 11:23:14 +08:00
parent a9b8c9bb39
commit b669a2b518
2 changed files with 7 additions and 1 deletions

View file

@ -8,6 +8,8 @@ import importlib
import json
from .utils import warn, py3, import_file
import re
import io
import platform
def _current_dir():
@ -238,5 +240,9 @@ def main():
segments.append(segment)
for segment in segments:
segment.add_to_powerline()
if platform.system() == 'Windows':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, 'utf-8' , line_buffering = True)
sys.stdout.write(powerline.draw())
return 0

View file

@ -14,7 +14,7 @@ class Segment(ThreadedSegment):
output = map(lambda l: int(l.split()[2].strip()),
output_proc.communicate()[0].decode("utf-8").splitlines()[1:])
self.num_jobs = output.count(os.getppid()) - 1
else:
elif platform.system() != 'Windows':
pppid_proc = subprocess.Popen(['ps', '-p', str(os.getppid()), '-oppid='],
stdout=subprocess.PIPE)
pppid = pppid_proc.communicate()[0].decode("utf-8").strip()