diff options
author | hut <hut@lavabit.com> | 2010-10-12 20:08:23 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-10-12 20:08:23 +0200 |
commit | a835c49a1663b4e69c3d900a16d9d64a9c29339b (patch) | |
tree | ff694ddcf59e7ee5b0b09c748ef3b98a4d6d4fc7 | |
parent | f331dffe14bf38e3f6d5bc21bc85c1c230432bb4 (diff) | |
download | ranger-a835c49a1663b4e69c3d900a16d9d64a9c29339b.tar.gz |
core.loader: decode stdout in >python3 in CommandLoader
-rw-r--r-- | ranger/core/loader.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 02e8c232..5e509e0b 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -21,6 +21,7 @@ from ranger.core.shared import FileManagerAware from ranger.ext.signal_dispatcher import SignalDispatcher import math import os +import sys import select @@ -73,6 +74,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware): yield sleep(0.03) else: + py3 = sys.version > '3' selectlist = [] if self.read: selectlist.append(process.stdout) @@ -86,19 +88,28 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware): rd = rd[0] if rd == process.stderr: read = rd.readline() + if py3: + read = read.decode('utf-8') if read: self.fm.notify(read, bad=True) elif rd == process.stdout: read = rd.read(512) + if py3: + read = read.decode('utf-8') if read: self.stdout_buffer += read except select.error: sleep(0.03) if not self.silent: for l in process.stderr.readlines(): + if py3: + l = l.decode('utf-8') self.fm.notify(l, bad=True) if self.read: - self.stdout_buffer += process.stdout.read() + read = process.stdout.read() + if py3: + read = read.decode('utf-8') + self.stdout_buffer += read self.finished = True self.signal_emit('after', process=process, loader=self) |