The action.launch hook is triggered from the ftrack interface when a user selects an action in the Actions menu. For more information about launching actions from the web UI, see ftrack:using/actions.
The list of actions is provided by the ftrack.action.discover hook. The action.discover hook provides a list of actions. All parameters from these actions are passed to this hook and can be used when launching the action.
The default hook is a placeholder and should be extended to include correct action commands.
Example event passed to hook:
Event( topic='ftrack.action.launch', data=dict( actionIdentifier='ftrack-connect-launch-applications-action', applicationIdentifier='maya-2014', foo='bar', selection=[ dict( entityId='eb16970c-5fc6-11e2-bb9a-f23c91df25eb', entityType='task' ) ] ) )
Expects reply data in the form:
dict( success=True, message='maya-2014 launched successfully.' )
class LaunchApplicationHook(object): def __init__(self, launcher): '''Initialise hook with *launcher*. *launcher* should be an instance of :class:`ftrack_connect.application.ApplicationLauncher`. ''' super(LaunchApplicationHook, self).__init__() self.logger = logging.getLogger( 'ftrack.hook.' + self.__class__.__name__ ) self.launcher = launcher def __call__(self, event): '''Handle *event*. event['data'] should contain: applicationIdentifier Identifier for the application to be launched. selection A list of selected entities for which to launch the application for. ''' applicationIdentifier = event['data']['applicationIdentifier'] context = event['data'].copy() context['source'] = event['source'] return self.launcher.launch( applicationIdentifier, context )