diff options
author | hut <hut@lavabit.com> | 2012-04-13 15:29:08 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2012-04-13 15:31:08 +0200 |
commit | 56549de7b6082ca095f89187b3531e630aa383b4 (patch) | |
tree | a7aa69dad70f1ecf15fea72534b2b2181d52c2bc | |
parent | 8e63339d1efcef454d5ab1a2b5b93b89a815e8ff (diff) | |
download | ranger-56549de7b6082ca095f89187b3531e630aa383b4.tar.gz |
ext.rifle: inline "spawn" function
-rwxr-xr-x | ranger/ext/rifle.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index c97b360d..09b234d7 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -20,13 +20,13 @@ Example usage: import os.path import re -from subprocess import Popen +from subprocess import Popen, PIPE import sys -from ranger.ext.spawn import spawn from ranger.ext.get_executables import get_executables DEFAULT_PAGER = 'less' DEFAULT_EDITOR = 'nano' +ENCODING = 'utf-8' def _is_terminal(): # Check if stdin (file descriptor 0), stdout (fd 1) and @@ -162,9 +162,11 @@ class Rifle(object): # Spawn "file" to determine the mime-type of the given file. if self._mimetype: return self._mimetype - mimetype = spawn("file", "--mime-type", "-Lb", fname) - self._mimetype = mimetype - return mimetype + process = Popen(["file", "--mime-type", "-Lb", fname], + stdout=PIPE, stderr=PIPE) + mimetype, _ = process.communicate() + self._mimetype = mimetype.decode(ENCODING) + return self._mimetype def _build_command(self, files, action, flags): # Get the flags |