GRIND-47: Turn hooks into a python context.

Helps with cleanup and disambiguation of hooks.

Change-Id: Id2b424c01586274c85dedf102bcedf1496a5c633
Merge "GRIND-47: Turn hooks into a python context."