Skip to content

Commit

Permalink
Merge pull request #247 from chelloiaco/master
Browse files Browse the repository at this point in the history
Added info for the user if (un)installation fails.
  • Loading branch information
miquelcampos authored Sep 1, 2023
2 parents c7c3ff7 + c3f88e1 commit 12d6b58
Showing 1 changed file with 64 additions and 16 deletions.
80 changes: 64 additions & 16 deletions drag_n_drop_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import shutil
import re
import traceback
from datetime import datetime

try:
Expand Down Expand Up @@ -275,21 +276,26 @@ def start_install(self):
cmds.loadModule(allModules=True)

# -- force load the plugins just in-case it does not happen
self.load_plugins()
failed_list = self.load_plugins()

# -- reload user setup files
basic.executeUserSetup()

self.update_logging_widget("Installation Successful!")
om.MGlobal.displayInfo("Installation Complete")
if len(failed_list):
self.update_logging_widget(
"Installation Unsuccessful, errors occurred!")
om.MGlobal.displayWarning("Installation Incomplete")
else:
self.update_logging_widget("Installation Successful!")
om.MGlobal.displayInfo("Installation Complete")

def start_uninstall(self, destination):
"""
Uninstall any existing folders on disk
:param destination: folder to remove files from.
"""

self.unload_plugins()
failed_list = self.unload_plugins()

# -- iterate over folders and remove them
for item in DEFAULT_ITEMS:
Expand All @@ -300,7 +306,11 @@ def start_uninstall(self, destination):
elif os.path.isdir(os.path.join(destination, item)):
self.remove_directory(os.path.join(destination, item))

self.update_logging_widget("Uninstalled Successfully!")
if len(failed_list):
self.update_logging_widget(
"Uninstall Unsuccessful, errors occurred!")
else:
self.update_logging_widget("Uninstalled Successfully!")

def update_env_file(self, env_file, install_path):
"""
Expand Down Expand Up @@ -514,33 +524,70 @@ def current_time(self):
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")

def unload_plugins(self):
"""Unload all of our plugins."""

"""
Unload all of our plugins.
:return: List of plugins that failed to load, if any
:rtype: list
"""
failed_list = []
for p in PLUGINS:
if self.is_plugin_loaded(p):
self.unload_plugin(p)
self.update_logging_widget("Unloaded {0} plugin".format(p))
status = self.unload_plugin(p)
if status == True:
self.update_logging_widget("Unloaded '{0}' plugin".format(p))
else:
self.update_logging_widget(
"Error: unable to unload '{0}' plugin!".format(p))
failed_list.append(p)

return failed_list

def load_plugins(self):
"""Load in all of our plugins if they are not already."""
"""
Load in all of our plugins if they are not already.
:return: List of plugins that failed to load, if any
:rtype: list
"""
failed_list = []
for p in PLUGINS:
if not self.is_plugin_loaded(p):
self.load_plugin(p)
self.update_logging_widget("Loaded {0} plugin".format(p))
status = self.load_plugin(p)
if status == True:
self.update_logging_widget("Loaded '{0}' plugin".format(p))
else:
self.update_logging_widget(
"Error: unable to load '{0}' plugin!".format(p))
failed_list.append(p)

return failed_list

def unload_plugin(self, plugin_name):
"""Helper function to unload the specified plugins."""
"""
Helper function to unload the specified plugins.
:param str plugin_name: the name of the plugin to unload
:return: True, if plugin sucessfully unloaded
:rtype: bool
"""
try:
cmds.unloadPlugin(plugin_name, force=True)
return True
except:
pass
self.update_logging_widget(traceback.format_exc())
return False

def load_plugin(self, plugin_name):
"""Helper function to load the specified plugins."""
"""
Helper function to load the specified plugins.
:param str plugin_name: the name of the plugin to load
:return: True, if plugin sucessfully loaded
:rtype: bool
"""
try:
cmds.loadPlugin(plugin_name)
return True
except:
pass
self.update_logging_widget(traceback.format_exc())
return False

def is_plugin_loaded(self, plugin_name):
"""
Expand Down Expand Up @@ -649,5 +696,6 @@ def _dropped_install():
installer_window = InstallUI()
installer_window.show()


if is_maya:
_dropped_install()

0 comments on commit 12d6b58

Please sign in to comment.