diff -r 18b3b1926720 -r e22d9f699081 degal/command.py --- a/degal/command.py Fri Jun 05 23:41:57 2009 +0300 +++ b/degal/command.py Fri Jun 05 23:42:03 2009 +0300 @@ -2,7 +2,7 @@ Command implementations """ -import inspect, logging +import inspect, logging, traceback class CommandList (object) : """ @@ -44,12 +44,12 @@ self.func = func self.doc = doc - def invoke (self, config, gallery, args, options) : + def setup (self, config, gallery) : """ Run the command with the given context """ - return CommandContext(self, config, gallery)(*args, **options) + return CommandContext(self, config, gallery) class CommandContext (object) : """ @@ -101,16 +101,27 @@ print msg def log_debug (self, msg, *args, **kwargs) : - log_msg(logging.DEBUG, msg, *args, **kwargs) + self.log_msg(logging.DEBUG, msg, *args, **kwargs) def log_info (self, msg, *args, **kwargs) : - log_msg(logging.INFO, msg, *args, **kwargs) + self.log_msg(logging.INFO, msg, *args, **kwargs) def log_warning (self, msg, *args, **kwargs) : - log_msg(logging.WARNING, msg, *args, **kwargs) + self.log_msg(logging.WARNING, msg, *args, **kwargs) def log_error (self, msg, *args, **kwargs) : - log_msg(logging.ERROR, msg, *args, **kwargs) + self.log_msg(logging.ERROR, msg, *args, **kwargs) + + def handle_error (self, exc_info=None) : + """ + Do something to handle an error that occured + """ + + if exc_info : + traceback.print_execption(*exc_info) + + else : + traceback.print_exc() def command (func) : """