diff options
author | hut <hut@lavabit.com> | 2010-10-08 22:11:11 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-10-08 22:11:11 +0200 |
commit | 37ea434a29e7919e5aca9a13374a6d5d380d4eb5 (patch) | |
tree | fccf60b5ac267ac2afb625d869103efb7eb777ec /ranger | |
parent | c1f3125c53152b4eaa554a5e4d3a2ee2dbd6dfd8 (diff) | |
download | ranger-37ea434a29e7919e5aca9a13374a6d5d380d4eb5.tar.gz |
ranger.core.loader: allow suppressing errors in CommandLoader
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/loader.py | 32 | ||||
-rw-r--r-- | ranger/fsobject/file.py | 2 |
2 files changed, 20 insertions, 14 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py index c03ecc29..1ea50f4d 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -55,27 +55,33 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware): object is removed from the queue (type ^C in ranger) """ finished = False - def __init__(self, args, descr): + def __init__(self, args, descr, silent=False): SignalDispatcher.__init__(self) Loadable.__init__(self, self.generate(), descr) self.args = args + self.silent = silent def generate(self): self.process = process = Popen(self.args, stdout=PIPE, stderr=PIPE) self.signal_emit('before', process=process) - while process.poll() is None: - try: - rd, _, __ = select.select( - [process.stderr], [], [], 0.05) - if rd: - error = process.stderr.readline().decode('utf-8') - if error: - self.fm.notify(error, bad=True) - except select.error: - pass -# sleep(0.02) - yield + if self.silent: + while process.poll() is None: + yield + sleep(0.02) + else: + while process.poll() is None: + yield + try: + rd, _, __ = select.select( + [process.stderr], [], [], 0.03) + if rd: + error = process.stderr.readline().decode('utf-8') + if error: + self.fm.notify(error, bad=True) + except select.error: + pass + sleep(0.01) self.finished = True self.signal_emit('after', process=process) diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py index 2701537c..4076b136 100644 --- a/ranger/fsobject/file.py +++ b/ranger/fsobject/file.py @@ -111,7 +111,7 @@ class File(FileSystemObject): self.preview_loading = True loadable = CommandLoader(args=[self.fm.settings.preview_script, self.path, str(width), str(height)], - descr="Getting preview of %s" % self.path) + silent=True, descr="Getting preview of %s" % self.path) loadable.signal_bind('after', self._update_preview, weak=True) self.fm.loader.add(loadable) return None |