From c815115cae6e6b86f0de64acece0c0310690b3b5 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Tue, 19 Jan 2021 10:18:48 -0600 Subject: [PATCH] library file path bugs --- src/Mod/Path/PathScripts/PathPreferences.py | 3 ++- src/Mod/Path/PathScripts/PathToolBitLibraryGui.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py index 5b3760a767..dfab692aee 100644 --- a/src/Mod/Path/PathScripts/PathPreferences.py +++ b/src/Mod/Path/PathScripts/PathPreferences.py @@ -299,7 +299,8 @@ def lastPathToolLibrary(): def setLastPathToolLibrary(path): PathLog.track(path) curLib = lastFileToolLibrary() - if os.path.split(curLib)[0] != path: + PathLog.debug('curLib: {}'.format(curLib)) + if curLib and os.path.split(curLib)[0] != path: setLastFileToolLibrary('') # a path is known but not specific file return preferences().SetString(LastPathToolLibrary, path) diff --git a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py index dd91d78c4a..7993baaf6b 100644 --- a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py +++ b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py @@ -383,6 +383,8 @@ class ToolBitLibrary(object): workingdir = os.path.dirname(PathPreferences.lastPathToolLibrary()) defaultdir = os.path.dirname(PathPreferences.pathDefaultToolsPath()) + PathLog.debug('workingdir: {} defaultdir: {}'.format(workingdir, defaultdir)) + dirOK = lambda : workingdir != defaultdir and (os.access(workingdir, os.W_OK)) if dirOK(): @@ -400,6 +402,7 @@ class ToolBitLibrary(object): PathPreferences.filePath()) PathPreferences.setLastPathToolLibrary("{}/Library".format(workingdir)) + PathLog.debug('setting workingdir to: {}'.format(workingdir)) subdirlist = ['Bit', 'Library', 'Shape'] mode = 0o777 @@ -605,8 +608,9 @@ class ToolBitLibrary(object): else: tools.append({'nr': toolNr, 'path': PathToolBit.findRelativePathTool(toolPath)}) - with open(self.path, 'w') as fp: - json.dump(library, fp, sort_keys=True, indent=2) + if self.path is not None: + with open(self.path, 'w') as fp: + json.dump(library, fp, sort_keys=True, indent=2) def libraryOk(self): self.librarySave()