diff options
author | hut <hut@lepus.uberspace.de> | 2016-11-04 14:15:10 -0400 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2016-11-04 14:15:10 -0400 |
commit | 7cb2731d77a24dfca19720d1c207d4ef88676235 (patch) | |
tree | e9da27304bea2dd371fb9ccf971fd313992a8179 /ranger | |
parent | f38b13af371bb87880a65cf0cc52e12ddab64042 (diff) | |
parent | 6f9c106aa352c3e13f34c4216a4516b4c18e452b (diff) | |
download | ranger-7cb2731d77a24dfca19720d1c207d4ef88676235.tar.gz |
Merge branch 'subprocess_check_output' of https://github.com/richboss/ranger
Diffstat (limited to 'ranger')
-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..f63cb142 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(["file", "-bL", file.path], stdout=PIPE) + 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 cb8137e3..a101e3f4 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(cmd, cwd=path, stdout=subprocess.PIPE, 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: |