6. Acessing messages, exceptions, and tracebacksΒΆ

Elsware collects all exception messages and tracebacks into an accessible place - which you can use in other actions to send emails, or print to stdout.

The messages object is defined in elsware.support.Messages. The built-in stdout action uses it, here’s an example:

class StdoutAction(base.BaseAction):
        def finalize(self):
                if len(self.deployment.messages.messages)>0:
                        print "----MESSAGES----\n"
                        for message in self.deployment.messages.messages: print message
                        print "\n"
                if len(self.deployment.messages.run_exceptions)>0:
                        print "----RUN EXCEPTIONS----\n"
                        for message in self.deployment.messages.run_exceptions: print message
                        print "\n"
                if len(self.deployment.messages.revert_exceptions)>0:
                        print "----REVERT EXCAPTIONS----\n"
                        for message in self.deployment.messages.revert_exceptions: print message

You can also save any arbitrary message, here’s another example:

class TestAction(base.BaseAction):
        def finalize(self):
                self.messages.message("HELLO WORLD")

Previous topic

5. Saving state with client objects

Next topic

7. Pre-built Actions

This Page