From db79a87439b260c762a43636e01eb6dfedc548f4 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Tue, 17 Jul 2012 14:42:35 +0100 Subject: new global 'call' command to execute python code issue #480 --- alot/commands/globals.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'alot') diff --git a/alot/commands/globals.py b/alot/commands/globals.py index dcf0c7a5..d7a4cee1 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -305,6 +305,29 @@ class PythonShellCommand(Command): ui.mainloop.screen.start() +@registerCommand(MODE, 'call', arguments=[ + (['command'], {'help':'python command string to call'})]) +class CallCommand(Command): + """ Executes python code """ + def __init__(self, command, **kwargs): + """ + :param command: python command string to call + :type command: str + """ + Command.__init__(self, **kwargs) + self.command = command + + def apply(self, ui): + hooks = settings.hooks + try: + exec self.command + except Exception as e: + logging.exception(e) + msg = 'an error occurred during execution of "%s":\n'\ + '%s\nSee the logfile for details' + ui.notify(msg % e, priority='error') + + @registerCommand(MODE, 'bclose') class BufferCloseCommand(Command): """close a buffer""" -- cgit v1.2.3