Replace Function Of Other Plugin#

This example plugin modifies the functionality of another plugin, by replacing a function with a new function (monkeypatching).

More information about this workflow can be found here.

See the section for Single File Plugins on how to load this example.


name = "PatchDeadline"
classname = "PatchDeadline"

class PatchDeadline:
    def __init__(self, core):
        self.core = core
        self.version = "v1.0.0"

        # check if Deadline plugin is loaded
        dlPlugin = self.core.getPlugin("Deadline")
        if dlPlugin:
            # if yes, patch the function

        # register callback in case the Deadline plugin will be loaded later on
        # this is important if the plugin gets loaded later on during the startup or manually by the user
            "pluginLoaded", self.onPluginLoaded, plugin=self

    def onPluginLoaded(self, plugin):
        # check if the loaded plugin is the Deadline plugin and if yes apply the patch
        if plugin.pluginName == "Deadline":

    def applyPatch(self, plugin):
        # apply the monkeypatch to the "getDeadlineGroups" function of the Deadline plugin
        self.core.plugins.monkeyPatch(plugin.getDeadlineGroups, self.getDeadlineGroups, self, force=True)

    def getDeadlineGroups(self):
        # the original function reads the groups from the project config
        # with this patch the groups are queried directly from Deadline
        groups = self.core.getPlugin("Deadline").refreshGroups()
        groups = groups or []
        return groups