Skip to content

Commit

Permalink
fix: catch import errors, link to libssl issue (#134)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Anderson <[email protected]>
  • Loading branch information
AWS-Samuel authored Mar 30, 2024
1 parent 450ddb4 commit af79694
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
30 changes: 21 additions & 9 deletions maya_submitter_plugin/plug-ins/DeadlineCloudForMaya.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
import maya.api.OpenMaya as om # pylint: disable=import-error
import maya.cmds

import deadline.maya_submitter
from deadline.maya_submitter import mel_commands, shelf # type: ignore[import, no-redef]

# Tells maya which version of their api to use.
maya_useNewAPI = True
VENDOR = "AWS"
Expand Down Expand Up @@ -53,6 +50,9 @@ def initializePlugin(plugin):
"""
global _registered_mel_commands, _first_initialization
try:
import deadline.maya_submitter
from deadline.maya_submitter import mel_commands, shelf # type: ignore[import, no-redef]

plugin_obj = om.MFnPlugin(plugin, VENDOR, VERSION)

if _first_initialization:
Expand Down Expand Up @@ -80,12 +80,23 @@ def initializePlugin(plugin):
shelf.build_shelf()

except Exception as e:
maya.cmds.confirmDialog(
title="Deadline Cloud For Maya Plugin Failed To Load",
message=(
if isinstance(
e, ImportError
) and "cannot import name 'ssl' from 'urllib3.util.ssl_'" in str(e.msg):
message = (
"Deadline Cloud Submitter could not load due to a known issue where Maya does not "
"link libssl and libcrypto on some operating systems. Please see the following link"
" for more information:\n"
"https://github.com/aws-deadline/deadline-cloud-for-maya/issues/133"
)
else:
message = (
"Encountered the following exception while loading the Deadline Cloud Submitter:\n"
f"{str(e)}"
),
)
maya.cmds.confirmDialog(
title="Deadline Cloud For Maya Plugin Failed To Load",
message=message,
button="OK",
defaultButton="OK",
)
Expand All @@ -98,10 +109,11 @@ def uninitializePlugin(plugin):
"""
plugin_obj = om.MFnPlugin(plugin)

__log__ = deadline.maya_submitter.logger()

for command_name in _registered_mel_commands:
try:
import deadline.maya_submitter

__log__ = deadline.maya_submitter.logger()
plugin_obj.deregisterCommand(command_name)
except Exception:
__log__.error(f"Failed to deregister command: {command_name}\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import deadline
from deadline.maya_submitter import maya_render_submitter
from deadline.maya_submitter import mel_commands
from deadline.maya_submitter import shelf
import DeadlineCloudForMaya

Command = namedtuple("Command", ["name", "cmdCreator"]) # Mock Command Class
Expand All @@ -36,7 +37,7 @@ def test_reload_modules(mock_reload: Mock) -> None:
@patch.object(om.MGlobal, "mayaState")
@patch.object(om, "MFnPlugin")
@patch.object(DeadlineCloudForMaya, "reload")
@patch.object(deadline.maya_submitter.shelf, "build_shelf")
@patch.object(shelf, "build_shelf")
@patch.dict(os.environ, {"DEADLINE_ENABLE_DEVELOPER_OPTIONS": "False"})
def test_initialize_and_uninitialize_plugin(
mock_build_shelf: Mock,
Expand Down

0 comments on commit af79694

Please sign in to comment.