From 11d519a7c3771c8a01ae45cb26803963d6bdb306 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 16 Oct 2011 15:58:00 +0100 Subject: fix ! for shellescape and error handling --- alot/commands/globals.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'alot/commands/globals.py') diff --git a/alot/commands/globals.py b/alot/commands/globals.py index fba07d93..0da6ba18 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -117,8 +117,11 @@ class ExternalCommand(Command): callerbuffer = ui.current_buffer def afterwards(data): - if callable(self.on_success) and data == 'success': - self.on_success() + if data == 'success': + if callable(self.on_success): + self.on_success() + else: + ui.notify(data, priority='error') if self.refocus and callerbuffer in ui.buffers: ui.logger.info('refocussing') ui.buffer_focus(callerbuffer) @@ -142,9 +145,11 @@ class ExternalCommand(Command): cmd) cmd = cmd.encode('utf-8', errors='ignore') ui.logger.info('calling external command: %s' % cmd) - returncode = subprocess.call(shlex.split(cmd)) - if returncode == 0: - os.write(write_fd, 'success') + try: + if 0 == subprocess.call(shlex.split(cmd)): + os.write(write_fd, 'success') + except OSError, e: + os.write(write_fd, str(e)) if self.in_thread: thread = threading.Thread(target=thread_code) -- cgit v1.2.3