# HG changeset patch # User Tero Marttila # Date 1244745639 -10800 # Node ID eb50b4f7812d04185d163a3f13c76360b65bcdfc # Parent 17ae33501289f14ed9e43e8d8c8f760f2166d96c move Command exception handling into command.py, and handle KeyboardInterrupt diff -r 17ae33501289 -r eb50b4f7812d degal/command.py --- a/degal/command.py Thu Jun 11 21:40:12 2009 +0300 +++ b/degal/command.py Thu Jun 11 21:40:39 2009 +0300 @@ -67,12 +67,27 @@ self.config = config self.gallery = gallery - def __call__ (self, *args, **kwargs) : + def execute (self, *args, **kwargs) : """ Run the command in this context """ return self.command.func(self, *args, **kwargs) + + def run (self, *args, **kwargs) : + """ + Run the command with error handling + """ + + try : + # run it + return self.execute(*args, **kwargs) + + except KeyboardInterrupt : + self.log_error("Interrupted") + + except : + command_ctx.handle_error() def log_msg (self, level, msg, *args, **kwargs) : """ diff -r 17ae33501289 -r eb50b4f7812d degal/main.py --- a/degal/main.py Thu Jun 11 21:40:12 2009 +0300 +++ b/degal/main.py Thu Jun 11 21:40:39 2009 +0300 @@ -71,13 +71,9 @@ # setup the command execution context command_ctx = command.setup(config, gallery) - - try : - # run it - return command_ctx(*args, **kwargs) - - except : - command_ctx.handle_error() + + # run with error handling + return command_ctx.run() def main (argv) : """