diff options
-rw-r--r-- | ranger/core/linemode.py | 11 | ||||
-rw-r--r-- | ranger/ext/vcs/vcs.py | 8 |
2 files changed, 16 insertions, 3 deletions
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py index 96557515..ca9fb86a 100644 --- a/ranger/core/linemode.py +++ b/ranger/core/linemode.py @@ -97,9 +97,16 @@ class FileInfoLinemode(LinemodeBase): def infostring(self, file, metadata): if not file.is_directory: - from subprocess import check_output, CalledProcessError + from subprocess import Popen, PIPE, CalledProcessError try: - fileinfo = check_output(["file", "-bL", file.path]).strip() + process = Popen(stdout=PIPE, "file", "-bL", file.path) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + error = subprocess.CalledProcessError(retcode, "file") + error.output = output + raise error + fileinfo = output.strip() except CalledProcessError: return "unknown" if sys.version_info[0] >= 3: diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py index 9c7be653..ed7838f7 100644 --- a/ranger/ext/vcs/vcs.py +++ b/ranger/ext/vcs/vcs.py @@ -119,7 +119,13 @@ class Vcs(object): # pylint: disable=too-many-instance-attributes with open(os.devnull, 'w') as devnull: try: if catchout: - output = subprocess.check_output(cmd, cwd=path, stderr=devnull) + process = subprocess.Popen(stdout=subprocess.PIPE, cmd, cwd=path, stderr=devnull) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + error = subprocess.CalledProcessError(retcode, cmd) + error.output = output + raise error if retbytes: return output else: |