module import helper
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import threading, sys, traceback, time
|
import threading, sys, traceback, time
|
||||||
|
|
||||||
from devsup.util import Worker
|
from devsup.util import Worker, importmod
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _dbapi
|
import _dbapi
|
||||||
@ -326,5 +326,5 @@ def processLink(name, lstr):
|
|||||||
rec = getRecord(name)
|
rec = getRecord(name)
|
||||||
parts = lstr.split(None,1)
|
parts = lstr.split(None,1)
|
||||||
modname, args = parts[0], parts[1] if len(parts)>1 else None
|
modname, args = parts[0], parts[1] if len(parts)>1 else None
|
||||||
mod = __import__(modname, fromlist=['__should_not_exist'])
|
mod = importmod(modname)
|
||||||
return rec, mod.build(rec, args)
|
return rec, mod.build(rec, args)
|
||||||
|
@ -6,6 +6,17 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import queue
|
import queue
|
||||||
|
|
||||||
|
def importmod(modname):
|
||||||
|
"""Import the named python module(s)
|
||||||
|
add return the leaf.
|
||||||
|
|
||||||
|
>>> M=importmod('xml.sax')
|
||||||
|
>>> M.__name__
|
||||||
|
'xml.sax'
|
||||||
|
>>>
|
||||||
|
"""
|
||||||
|
return __import__(modname, fromlist=['__should_not_exist'])
|
||||||
|
|
||||||
class StoppableThread(threading.Thread):
|
class StoppableThread(threading.Thread):
|
||||||
"""A thread which can be requested to stop.
|
"""A thread which can be requested to stop.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user