about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRichard Boß <richboss@gmail.de>2016-10-24 22:26:38 +0200
committerRichard Boß <richboss@gmail.de>2016-10-24 22:33:44 +0200
commit21312c3dc2721a5116b1d3d27255084390346ec5 (patch)
tree31922fd0ae1cb0dfa22601597a4c7ca184689e7a
parent041856327c0d9b1fe3f26c5447995fda477c657f (diff)
downloadranger-21312c3dc2721a5116b1d3d27255084390346ec5.tar.gz
fix issue #695: FileInfo Linemode crashes Ranger on Python 2.6
- replaced calls to subprocess.check_output by code downported from
  Python 2.7
-rw-r--r--ranger/core/linemode.py11
-rw-r--r--ranger/ext/vcs/vcs.py8
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: