Permalink
Browse files

Overhaul of event running stuff.

Improved docstrings and tests.
  • Loading branch information...
captainhammy committed Dec 1, 2018
1 parent e8a2c52 commit 73aae1e0e35f8a773d4feaeb73086b6d8049f91b
@@ -2,7 +2,18 @@
[run]
branch = True
source =
ht.inline
ht.events.callbacks
ht.events.event
ht.events.group
ht.events.item
ht.events.manager
ht.events.stats
ht.events.events.rop_render
ht.events.events.scene_load
ht.inline.api
ht.nodes.styles.event
ht.nodes.styles.styles
ht.nodes.styles.manager
ht.pyfilter.manager
ht.pyfilter.property
ht.pyfilter.utils
@@ -11,4 +11,4 @@
import ht.nodes.styles

# Create any dynamic event handlers, such as using Python's atexit module
ht.events.callbacks.registerCallbacks()
ht.events.callbacks.register_callbacks()
@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import SceneEvents, runEvent
from ht.events import SceneEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(SceneEvents.Load)
run_event(SceneEvents.Load)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.OnCreated, kwargs)
run_event(NodeEvents.OnCreated, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.OnDeleted, kwargs)
run_event(NodeEvents.OnDeleted, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.OnInputChanged, kwargs)
run_event(NodeEvents.OnInputChanged, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.OnLoaded, kwargs)
run_event(NodeEvents.OnLoaded, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.OnNameChanged, kwargs)
run_event(NodeEvents.OnNameChanged, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.OnUpdated, kwargs)
run_event(NodeEvents.OnUpdated, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.PostLastDelete, kwargs)
run_event(NodeEvents.PostLastDelete, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.PreFirstCreate, kwargs)
run_event(NodeEvents.PreFirstCreate, kwargs)

# =============================================================================

@@ -5,15 +5,15 @@
# =============================================================================

# Houdini Toolbox Imports
from ht.events import NodeEvents, runEvent
from ht.events import NodeEvents, run_event

# =============================================================================
# FUNCTIONS
# =============================================================================

def main():
"""Main function."""
runEvent(NodeEvents.SyncNodeVersion, kwargs)
run_event(NodeEvents.SyncNodeVersion, kwargs)

# =============================================================================

@@ -1,5 +1,5 @@
from ht.events import SceneEvents, runEvent
from ht.events import SceneEvents, run_event

# Perform any registered after scene save events.
runEvent(SceneEvents.PostSave, kwargs)
run_event(SceneEvents.PostSave, kwargs)

@@ -1,5 +1,5 @@
from ht.events import SceneEvents, runEvent
from ht.events import SceneEvents, run_event

# Perform any registered before scene save events.
runEvent(SceneEvents.PreSave, kwargs)
run_event(SceneEvents.PreSave, kwargs)

@@ -6,13 +6,13 @@

# Houdini Toolbox Imports
from ht.events.events import rop_render, scene_load
from ht.events.manager import registerEventBlock, registerEventGroup, registerFunction, runEvent
from ht.events.manager import register_event_group, register_function, register_item, run_event
from ht.events.types import NodeEvents, RopEvents, SceneEvents

# =============================================================================

# Register the package's ROP render script events.
registerEventGroup(rop_render.RopRenderEvent())
register_event_group(rop_render.RopRenderEvent())

# Register the package's SceneLoadEvent.
registerEventBlock(scene_load.SceneLoadEvent())
register_event_group(scene_load.SceneLoadEvent())
@@ -8,26 +8,71 @@
import atexit

# Houdini Toolbox Imports
from ht.events import SceneEvents, runEvent
from ht.events.manager import run_event
from ht.events.types import SceneEvents

# Houdini Imports
import hou

# =============================================================================
# NON-PUBLIC FUNCTIONS
# =============================================================================

def _registerAtExit():
def _atexit_callback(*args, **kwargs):
"""Run SceneEvents.Exit events.
:return:
"""
run_event(SceneEvents.Exit)


def _emit_ui_available(*args, **kwargs):
"""Run SceneEvents.WhenUIAvailable events.
:return:
"""
run_event(SceneEvents.WhenUIAvailable)


def _register_atexit():
"""Register a dummy function with Python's atexit system that will run
an event using the event system.
:return:
"""
def _atExitCallback(*args, **kwargs):
runEvent(SceneEvents.Exit)
atexit.register(_atexit_callback)


def _register_when_ui_available():
"""Register a function emits the SceneEvents.WhenUIAvailable event.
This will be emitted when the UI is first brought up and the event
loop begins running.
:return:
"""
# Import here in case UI is not available.
import hdefereval

# Emit the event after the event loop has run once.
hdefereval.executeDeferredAfterWaiting(_emit_ui_available, 1)

atexit.register(_atExitCallback)

# =============================================================================
# FUNCTIONS
# =============================================================================

def registerCallbacks():
"""Register any dynamic callback funcions."""
_registerAtExit()
def register_callbacks():
"""Register any dynamic callback functions.
:return:
"""
_register_atexit()

if hou.isUIAvailable():
_register_when_ui_available()
Oops, something went wrong.

0 comments on commit 73aae1e

Please sign in to comment.