Path: py3 fixes

Needed for unit tests to pass
This commit is contained in:
Peter Lama
2017-06-15 16:38:22 -04:00
committed by wmayer
parent f6a086dde0
commit 17031e2a24
7 changed files with 62 additions and 39 deletions

View File

@@ -34,13 +34,23 @@ class PostProcessor:
@classmethod
def load(cls, processor):
postname = processor + "_post"
exec("import %s as current_post" % postname)
namespace = {}
#can't modify function local scope with exec in python3
exec("from PathScripts import %s as current_post" % postname, namespace)
current_post = namespace['current_post']
# make sure the script is reloaded if it was previously loaded
# should the script have been imported for the first time above
# then the initialization code of the script gets executed twice
# resulting in 2 load messages if the script outputs one of those.
exec("reload(%s)" % 'current_post')
try:
# Python 2.7
exec("reload(%s)" % 'current_post')
except NameError:
# Python 3.4+
from importlib import reload
exec("reload(%s)" % 'current_post')
instance = PostProcessor(current_post)
instance.units = None