本文整理汇总了Python中EventHandlers.EventRouterLoad.EventRouterLoader.loadFromDirectories方法的典型用法代码示例。如果您正苦于以下问题:Python EventRouterLoader.loadFromDirectories方法的具体用法?Python EventRouterLoader.loadFromDirectories怎么用?Python EventRouterLoader.loadFromDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandlers.EventRouterLoad.EventRouterLoader
的用法示例。
在下文中一共展示了EventRouterLoader.loadFromDirectories方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Root
# 需要导入模块: from EventHandlers.EventRouterLoad import EventRouterLoader [as 别名]
# 或者: from EventHandlers.EventRouterLoad.EventRouterLoader import loadFromDirectories [as 别名]
class Root(controllers.RootController):
def __init__( self ):
self.eventloader = None
self.homeTemplate = None
def start(self):
log_versions()
# TODO validateTemplateDirectory() on WebBrickGateway.templates
persistFile = turbogears.config.get("client_profiles", None, False, "gateway" )
ClientProfiles.load( persistFile )
self.homeTemplate = turbogears.config.get("homepage", None, False, "gateway" )
cfgStr = turbogears.config.get("templateDirectory", None, False, "gateway" )
if cfgStr:
_log.info( "additional template directory %s" % (cfgStr) )
validateTemplateDirectory( cfgStr )
#WbConfigSettings.addTemplateDir( cfgStr )
sys.path.insert( 1, cfgStr )
import kid
_log.info( "Kid Paths %s" % (str(kid.path.paths)) )
### tempdir = tempdir[:-(len(tempsuf)-1)]
kid.path.insert( cfgStr )
_log.info( "Kid Paths %s" % (str(kid.path.paths)) )
cfgStr = turbogears.config.get("network", None, False, "wbcfg" )
if cfgStr:
WbConfigBase.addNetwork( cfgStr )
cfgStr = turbogears.config.get("webbrickDirectory", None, False, "wbcfg" )
if cfgStr:
WbConfigSettings.ConfDir = cfgStr
_log.info( "updated webbrick configuration directory %s" % (cfgStr) )
userDir = turbogears.config.get("despatchConfig", None, False, "gateway" )
sysDir = turbogears.config.get("despatchConfigSystem", None, False, "gateway" )
self.eventloader = EventRouterLoader()
# system files first.
self.eventloader.loadFromDirectories( [sysDir, userDir] )
#print WbConfigSettings_hga.ConfDir
#print WbConfigSettings.ConfDir
###self.panel = PanelRenderer.PanelRenderer()
self.local = LocalData.LocalData()
self.userinterface = UserInterface.UserInterface()
self.nameCache = Webbrick.WebbrickNodeNameCache()
self.wbsts = Webbrick.WebbrickStatusCache( self.nameCache )
self.wbcmd = Webbrick.WebbrickCommand( self.nameCache )
self.eventstate = EventState.EventState( )
self.discover = DiscoverHandler()
self.media = Media.Media()
# need to handle discovery better
self.wbcnf = WbCfgManagerForm( self.discover )
# THIS IS FOR ARMOUR gateway config and discovery only
if ARMOUR_DEV:
self.wbgwcnf = WbGwCfgManager()
self.schedule = Schedule.Schedule()
self.sendevent = SendEvent.SendEventLocal(self.eventloader.getEventRouter())
self.wbproxy = Webbrick.WebbrickProxy()
self.eventstate.start(self.eventloader.getEventRouter())
self.nameCache.start(self.eventloader.getEventRouter())
self.wbsts.start(self.eventloader.getEventRouter())
self.discover.start(self.eventloader.getEventRouter())
self.schedule.start()
self.media.start(self.eventloader.getEventRouter())
# event handlers last
if self.eventloader:
self.eventloader.start()
if not self.eventloader.getEventRouter():
print "EVENT DESPATCH TASK NOT LOADED/FAILED CONFIGURE"
_log.info( "Sys Paths %s" % (sys.path) )
# Now publish the versions
router = self.eventloader.getEventRouter()
publish_versions(router)
import kid
_log.info( "Kid Paths %s" % (str(kid.path.paths)) )
_log.warning( "**** System Configured ****" )
def stop(self):
"""
helper to shut down some class stuff.
"""
#.........这里部分代码省略.........
示例2: TestEventRouterLoad
# 需要导入模块: from EventHandlers.EventRouterLoad import EventRouterLoader [as 别名]
# 或者: from EventHandlers.EventRouterLoad.EventRouterLoader import loadFromDirectories [as 别名]
#.........这里部分代码省略.........
self._loader.loadHandlers( getDictFromXmlString(testConfigDefault) )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testConfigureThreaded(self):
"""
Test loading a single event handler
"""
_log.debug( "\ntestConfigureThreaded" )
self._loader = EventRouterLoader()
self._loader.loadHandlers( getDictFromXmlString(testConfigThreaded) )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testConfigureRouter(self):
"""
Test loading a single event handler
"""
_log.debug( "\ntestConfigureRouter" )
self._loader = EventRouterLoader()
self._loader.loadHandlers( getDictFromXmlString(testConfigRouter) )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
self._loader.stop() # all tasks
def testConfigurePubSub(self):
"""
Test loading a single event handler
"""
_log.debug( "\ntestConfigurePubSub" )
self._loader = EventRouterLoader()
self._loader.loadHandlers( getDictFromXmlString(testConfigPubSub) )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testFileConfigure(self):
_log.debug( "\ntestDirectoryConfigure" )
self._loader = EventRouterLoader()
self._loader.loadFromFile( "./resources/testEventRouterLoad/fromFile.xml" )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testDirectoryConfigure(self):
_log.debug( "\ntestDirectoryConfigure" )
self._loader = EventRouterLoader()
self._loader.loadFromDirectories( "./resources/testEventRouterLoad/fromDirLoad" )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testDirectoriesConfigure(self):
_log.debug( "\ntestDirectoryConfigure" )
self._loader = EventRouterLoader()
self._loader.loadFromDirectories( "./resources/testEventRouterLoad/fromDirLoad1:./resources/testEventRouterLoad/fromDirLoad2" )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testConfigureMultiple(self):
"""
Test loading a single event handler
"""
_log.debug( "\ntestConfigureMultiple" )
self._loader = EventRouterLoader()
self._loader.loadHandlers( getDictFromXmlString(testConfigMultiple1) )
self._loader.loadHandlers( getDictFromXmlString(testConfigMultiple2) )
self._loader.start() # all tasks
self._router = self._loader.getEventRouter()
self.doSimpleTest()
def testDummy(self):
return