From 25d5c495775e9ec9e892b00d4b4fa6dbd5545451 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 18 Jun 2017 12:12:17 -0700 Subject: [PATCH] Fixed post processor loading. --- src/Mod/Path/PathScripts/PathPostProcessor.py | 15 ++++++++++++++- src/Mod/Path/PathScripts/PathPreferences.py | 10 ++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathPostProcessor.py b/src/Mod/Path/PathScripts/PathPostProcessor.py index e706439396..5b7471e7c5 100644 --- a/src/Mod/Path/PathScripts/PathPostProcessor.py +++ b/src/Mod/Path/PathScripts/PathPostProcessor.py @@ -23,8 +23,13 @@ # *************************************************************************** import FreeCAD +import PathScripts.PathLog as PathLog +import sys + from PathScripts.PathPreferences import PathPreferences +PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) + class PostProcessor: @classmethod @@ -33,11 +38,17 @@ class PostProcessor: @classmethod def load(cls, processor): + PathLog.track(processor) + syspath = sys.path + paths = PathPreferences.searchPaths() + paths.extend(sys.path) + sys.path = paths + postname = processor + "_post" namespace = {} #can't modify function local scope with exec in python3 - exec("from PathScripts import %s as current_post" % postname, namespace) + exec("import %s as current_post" % postname, namespace) current_post = namespace['current_post'] # make sure the script is reloaded if it was previously loaded @@ -52,6 +63,8 @@ class PostProcessor: from importlib import reload exec("reload(%s)" % 'current_post') + sys.path = syspath + instance = PostProcessor(current_post) instance.units = None if hasattr(current_post, "UNITS"): diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py index 719dff0d20..0765780c5d 100644 --- a/src/Mod/Path/PathScripts/PathPreferences.py +++ b/src/Mod/Path/PathScripts/PathPreferences.py @@ -53,12 +53,10 @@ class PathPreferences: @classmethod def allAvailablePostProcessors(cls): - posts = glob.glob(cls.pathScriptsSourcePath() + '/*_post.py') - allposts = [ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts] - - posts = glob.glob(cls.macroFilePath() + '/*_post.py') - - allposts.extend([ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts]) + allposts = [] + for path in cls.searchPaths(): + posts = [ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in glob.glob(path + '/*_post.py')] + allposts.extend(posts) allposts.sort() return allposts