From e55621233dc9a4d6dea70b8b07a17f6f2c65c945 Mon Sep 17 00:00:00 2001 From: krathjen Date: Thu, 28 Sep 2017 16:18:07 +0100 Subject: [PATCH] Fix error after renaming a folder Fix database error when no database file exists Fix maya items not showing outside of maya --- config.py | 6 +++--- database.py | 6 ++++++ librarywidget.py | 2 +- packages/studiolibrarymaya/__init__.py | 10 ++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config.py b/config.py index c08a7ac6..d4d1e61f 100644 --- a/config.py +++ b/config.py @@ -13,6 +13,6 @@ import studiolibrary -if studiolibrary.isMaya(): - import studiolibrarymaya - studiolibrarymaya.setup() + +import studiolibrarymaya +studiolibrarymaya.setup() diff --git a/database.py b/database.py index 6f39fbc2..5cc43d85 100644 --- a/database.py +++ b/database.py @@ -224,6 +224,12 @@ def _write(self, data): data = data.replace(relPath, '.') data = data.replace(relPath2, '..') + path = self.path() + + dirname = os.path.dirname(path) + if not os.path.exists(dirname): + os.makedirs(dirname) + with open(self.path(), "w") as f: # Test the given data by converting it to a json object. diff --git a/librarywidget.py b/librarywidget.py index efea7300..875a3694 100644 --- a/librarywidget.py +++ b/librarywidget.py @@ -740,7 +740,7 @@ def showFolderRenameDialog(self, parent=None): if accept: path = studiolibrary.renamePath(path, name) self.refreshFolders() - self.selectedFolderPath(path) + self.selectFolderPath(path) def showCreateFolderDialog(self, parent=None): """ diff --git a/packages/studiolibrarymaya/__init__.py b/packages/studiolibrarymaya/__init__.py index 66c75188..79dc9e63 100644 --- a/packages/studiolibrarymaya/__init__.py +++ b/packages/studiolibrarymaya/__init__.py @@ -116,7 +116,12 @@ def setup(): :rtype: None """ - import studiolibrarymaya.mayalibrarywidget + try: + import studiolibrarymaya.mayalibrarywidget + # Enable the Maya closed event + enableMayaClosedEvent() + except ImportError, e: + logging.exception(e) # The following items are registered on import. from studiolibrarymaya import animitem @@ -124,9 +129,6 @@ def setup(): from studiolibrarymaya import mirroritem from studiolibrarymaya import setsitem - # Enable the Maya closed event - enableMayaClosedEvent() - def enableMayaClosedEvent(): """