Every so often I get an error when importing a script module stored in the gateway global script library. The error is ImportError: No module named shared
from shared.util.MWESLogging import getLog import sys
I have also tried to use import shared.util.MWESLogging as mwesLogging and called the method with mwesLogging.getLog because I read in one of the other posts that the “from” method of importing sometimes has issues. But I get the same error.
Usually the methods work, but sometimes it fails and I’d like to know why. I tried putting it in the project script library but then it just said it couldn’t find the “project” module instead of the “shared” module.
I have attempted to move at least this code which is used all over the place! into a custom method attached to the project’s header line window or navigation window and while that works somewhat it complains at startup of the project because those windows are not always started first.
I have complained to IA about this problem with a different project that was using mostly server side scripts called from blocks in the SFC charting, but did not get a resolution to that problem.
I’ve got one window with multiple reused sub components (templates) where I get 300-400 errors, that I switched over to a combination of
win=system.gui.getWindow("Header Line") logger=win.getLogger(....)
The window getLogger method does the EXACT SAME IMPORT, and it works there!
The additional problem is that this isn’t the only method I have in the shared script libraries, it’s just the method used the most. I am having similar issues with other methods, where I’ve just copied them into the window elements as custom methods which is not really nice.