diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-07-17 14:42:35 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-07-17 14:42:35 +0100 |
commit | db79a87439b260c762a43636e01eb6dfedc548f4 (patch) | |
tree | f598329158a2412e47afb1946cdc849f91e42e7b /alot | |
parent | acfaf1f9b8a4ad6b6e8cc1f6b56da0c0afbc76cf (diff) |
new global 'call' command to execute python code
issue #480
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/globals.py | 23 |
1 files changed, 23 insertions, 0 deletions
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""" |