Report III
Exception messages are useful, but what would make it even more useful is progress messages. Something that can tell us more about the why of an exception.
Progress messages are made using the standard Python logging mechanism.
Here is what we will be developing in this example.
1 CollectCaptainAmerica -> None
0 ValidateCaptainAmerica -> Captain America
+-- INFO: Entering validator..
+-- INFO: About to validate instance: "Captain America"
+-- WARNING: Something is not right, aborting..
+-- EXCEPTION: Captain America must be a heroFor this, we will utilise the built-in logger.
class ValidateCaptainAmerica(pyblish.api.InstancePlugin):
order = pyblish.api.ValidatorOrder
def process(self, instance):
self.log.info("Entering validator..")
self.log.info("About to validate instance: %s" % instance)
if not instance.data["isHero"]:
self.log.warning("Something is not right.. aborting")
raise Exception("%s must be a hero" % instance)Now it's time to format the results.
Putting it all together, here is the full source code.
Last updated
Was this helpful?