mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
Merge pull request #2062 from Ellipsanime/add-maya-pyblish-plugins
Maya: validate authorized loaded plugins
This commit is contained in:
commit
783a4c1ce3
3 changed files with 78 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
import pyblish.api
|
||||
import maya.cmds as cmds
|
||||
import openpype.api
|
||||
import os
|
||||
|
||||
|
||||
class ValidateLoadedPlugin(pyblish.api.ContextPlugin):
|
||||
"""Ensure there are no unauthorized loaded plugins"""
|
||||
|
||||
label = "Loaded Plugin"
|
||||
order = pyblish.api.ValidatorOrder
|
||||
host = ["maya"]
|
||||
actions = [openpype.api.RepairContextAction]
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, context):
|
||||
|
||||
invalid = []
|
||||
loaded_plugin = cmds.pluginInfo(query=True, listPlugins=True)
|
||||
# get variable from OpenPype settings
|
||||
whitelist_native_plugins = cls.whitelist_native_plugins
|
||||
authorized_plugins = cls.authorized_plugins or []
|
||||
|
||||
for plugin in loaded_plugin:
|
||||
if not whitelist_native_plugins and os.getenv('MAYA_LOCATION') \
|
||||
in cmds.pluginInfo(plugin, query=True, path=True):
|
||||
continue
|
||||
if plugin not in authorized_plugins:
|
||||
invalid.append(plugin)
|
||||
|
||||
return invalid
|
||||
|
||||
def process(self, context):
|
||||
|
||||
invalid = self.get_invalid(context)
|
||||
if invalid:
|
||||
raise RuntimeError(
|
||||
"Found forbidden plugin name: {}".format(", ".join(invalid))
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def repair(cls, context):
|
||||
"""Unload forbidden plugins"""
|
||||
|
||||
for plugin in cls.get_invalid(context):
|
||||
cmds.pluginInfo(plugin, edit=True, autoload=False)
|
||||
cmds.unloadPlugin(plugin, force=True)
|
||||
|
|
@ -169,6 +169,11 @@
|
|||
"enabled": false,
|
||||
"attributes": {}
|
||||
},
|
||||
"ValidateLoadedPlugin": {
|
||||
"enabled": false,
|
||||
"whitelist_native_plugins": false,
|
||||
"authorized_plugins": []
|
||||
},
|
||||
"ValidateRenderSettings": {
|
||||
"arnold_render_attributes": [],
|
||||
"vray_render_attributes": [],
|
||||
|
|
|
|||
|
|
@ -82,6 +82,32 @@
|
|||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
"key": "ValidateLoadedPlugin",
|
||||
"label": "Validate Loaded Plugin",
|
||||
"checkbox_key": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "enabled",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "whitelist_native_plugins",
|
||||
"label": "Whitelist Maya Native Plugins"
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"key": "authorized_plugins",
|
||||
"label": "Authorized plugins",
|
||||
"object_type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue