summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Roversi <diegor@tiscali.it>2019-09-20 11:26:13 +0200
committerDiego Roversi <diegor@tiscali.it>2019-09-20 11:26:13 +0200
commit292c8b2b06c71ef4f08b3b99a3545365261ef2d2 (patch)
tree02ea4729a871dc996d0867b9fb22938d78eddf38
parent4f178917c2a1bf78a612454fd830b87d78dd1772 (diff)
fix dynamic import
-rw-r--r--display/modes.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/display/modes.py b/display/modes.py
index 0ac680e..c43638d 100644
--- a/display/modes.py
+++ b/display/modes.py
@@ -1,4 +1,7 @@
import sys
+import importlib
+import traceback
+# import display.dpy_pygame
KeyPressed = 2
KeyReleased = 3
@@ -32,20 +35,27 @@ class Mode:
self.url = url
def getmodule(self):
- return __import__(self.prefix + self.name.lower(), globals(),
- locals(), ['available'])
+# import dpy_pygame
+ print( f"getmodule __import__ {self.prefix}{self.name.lower()}", file=sys.stderr )
+ return importlib.import_module( "display." + self.prefix + self.name.lower() )
+ #__import__(self.prefix + self.name.lower(), globals(),
+ # locals(), ['available'])
def imperror(self):
try:
return self.__imperror
except AttributeError:
try:
+ print( f"getmodule = {self}" )
module = self.getmodule()
- except ImportError:
+ except ImportError as e:
result = 'not installed'
+ print("== ImportError traceback:", file=sys.stderr )
+ traceback.print_exc(file=sys.stderr)
else:
result = hasattr(module, 'imperror') and module.imperror()
self.__imperror = result
+ print( f"imperror result={result}" )
return result
def unique_id(self):