rearrange system startup so that components are not registered during initial import but via a controlled setup
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2500 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
5aee688a12
commit
e4108ed7d1
14 changed files with 313 additions and 268 deletions
|
@ -1,4 +1,4 @@
|
||||||
================================================
|
================================================
|
||||||
Agents for Job Execution and Communication Tasks
|
Agents for Job Execution and Communication Tasks
|
||||||
================================================
|
================================================
|
||||||
|
|
||||||
|
@ -101,8 +101,10 @@ configuration are provided by the controller.
|
||||||
So we are now ready to create a master agent and configure it by supplying
|
So we are now ready to create a master agent and configure it by supplying
|
||||||
the path to the configuration file.
|
the path to the configuration file.
|
||||||
|
|
||||||
>>> from cybertools.agent.base.agent import Master
|
>>> from cybertools.agent.main import setup
|
||||||
>>> master = Master(configFile)
|
>>> master = setup(configFile)
|
||||||
|
Starting agent application...
|
||||||
|
Using controllers base.sample.
|
||||||
>>> configFile.close()
|
>>> configFile.close()
|
||||||
|
|
||||||
>>> master.config
|
>>> master.config
|
||||||
|
@ -201,8 +203,9 @@ the twisted reactor.
|
||||||
... scheduler(name='core')
|
... scheduler(name='core')
|
||||||
... logger(name='default', standard=30)
|
... logger(name='default', standard=30)
|
||||||
... '''
|
... '''
|
||||||
>>> master = Master(config)
|
>>> master = setup(config)
|
||||||
>>> master.setup()
|
Starting agent application...
|
||||||
|
Using controllers core.sample.
|
||||||
|
|
||||||
>>> master.scheduler
|
>>> master.scheduler
|
||||||
<cybertools.agent.core.schedule.Scheduler object ...>
|
<cybertools.agent.core.schedule.Scheduler object ...>
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
"""
|
"""
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# register default adapters
|
|
||||||
|
|
||||||
from cybertools.agent.base import agent, control, job, log, schedule
|
|
||||||
from cybertools.agent.core import agent, control, schedule
|
|
||||||
from cybertools.agent.control import cmdline
|
|
||||||
from cybertools.agent.crawl import base
|
|
||||||
|
|
|
@ -60,22 +60,24 @@ class Master(Agent):
|
||||||
|
|
||||||
name = 'master'
|
name = 'master'
|
||||||
scheduler = None
|
scheduler = None
|
||||||
|
logger = None
|
||||||
|
|
||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
if isinstance(configuration, Configurator):
|
if isinstance(configuration, Configurator):
|
||||||
config = configuration
|
self.config = configuration
|
||||||
else: # configuration is path to config file
|
else: # configuration is path to config file
|
||||||
config = self.config = Configurator()
|
self.config = Configurator()
|
||||||
config.load(configuration)
|
self.config.load(configuration)
|
||||||
self.master = self
|
self.master = self
|
||||||
self.controllers = []
|
self.controllers = []
|
||||||
self.children = {}
|
self.children = {}
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
config = self.config
|
||||||
self.logger = loggers(self, name=config.logger.name)
|
self.logger = loggers(self, name=config.logger.name)
|
||||||
for n in config.controller.names:
|
for n in config.controller.names:
|
||||||
self.controllers.append(controllers(self, n))
|
self.controllers.append(controllers(self, n))
|
||||||
self.scheduler = schedulers(self, name=config.scheduler.name)
|
self.scheduler = schedulers(self, name=config.scheduler.name)
|
||||||
|
|
||||||
def setup(self):
|
|
||||||
for cont in self.controllers:
|
for cont in self.controllers:
|
||||||
cont.setup()
|
cont.setup()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Common stuff.
|
Miscellaneous common stuff.
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -4,15 +4,15 @@ Agents for Job Execution and Communication Tasks
|
||||||
|
|
||||||
($Id$)
|
($Id$)
|
||||||
|
|
||||||
>>> from cybertools.agent.base.agent import Master
|
|
||||||
|
|
||||||
>>> config = '''
|
>>> config = '''
|
||||||
... controller(names=['core.sample'])
|
... controller(names=['core.sample'])
|
||||||
... scheduler(name='core')
|
... scheduler(name='core')
|
||||||
... logger(name='default', standard=30)
|
... logger(name='default', standard=30)
|
||||||
... '''
|
... '''
|
||||||
>>> master = Master(config)
|
>>> from cybertools.agent.main import setup
|
||||||
>>> master.setup()
|
>>> master = setup(config)
|
||||||
|
Starting agent application...
|
||||||
|
Using controllers core.sample.
|
||||||
|
|
||||||
|
|
||||||
Crawler
|
Crawler
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
"""
|
"""
|
||||||
Outlook Crawler Class.
|
Outlook Crawler Class.
|
||||||
|
|
||||||
$Id: mail.py 2493 2008-04-03 11:17:37Z helmutm $
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
from cybertools.agent.crawl.mail import MailCrawler
|
|
||||||
|
|
||||||
class OutlookCrawlerStub(MailCrawler):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def findOutlook(self):
|
|
||||||
print "Returning reference to Outlook Application"
|
|
||||||
|
|
||||||
def fetchCriteria(self):
|
|
||||||
print "Retrieving Parameters"
|
|
||||||
|
|
||||||
def crawlFolders(self):
|
|
||||||
print "Crawling Folders"
|
|
||||||
self.loadMailsFromFolder()
|
|
||||||
|
|
||||||
def loadMailsFromFolder(self):
|
|
||||||
print "loading mails from folder"
|
|
||||||
self.createResource("SampleMail", "OutlookStubFolder", "OutlookStub")
|
|
|
@ -41,11 +41,22 @@ def getConfig():
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup(configInfo=None):
|
||||||
master = Master(getConfig())
|
if configInfo is None:
|
||||||
|
configInfo = getConfig()
|
||||||
|
master = Master(configInfo)
|
||||||
|
setupEnvironment(master.config)
|
||||||
master.setup()
|
master.setup()
|
||||||
print 'Starting agent application...'
|
print 'Starting agent application...'
|
||||||
print 'Using controllers %s.' % ', '.join(master.config.controller.names)
|
print 'Using controllers %s.' % ', '.join(master.config.controller.names)
|
||||||
|
return master
|
||||||
|
|
||||||
|
|
||||||
|
def setupEnvironment(config):
|
||||||
|
from cybertools.agent.base import agent, control, job, log, schedule
|
||||||
|
from cybertools.agent.core import agent, control, schedule
|
||||||
|
from cybertools.agent.control import cmdline
|
||||||
|
from cybertools.agent.crawl import base #, outlook
|
||||||
|
|
||||||
|
|
||||||
def startReactor():
|
def startReactor():
|
||||||
|
|
4
agent/system/__init__.py
Normal file
4
agent/system/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
4
agent/system/windows/__init__.py
Normal file
4
agent/system/windows/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
24
agent/system/windows/api.py
Normal file
24
agent/system/windows/api.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Conficuration-controlled import of Windows API functions.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
24
agent/testing/winapi.py
Normal file
24
agent/testing/winapi.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Fake Windows API functions for testing purposes.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
|
@ -43,7 +43,7 @@ def test_suite():
|
||||||
unittest.makeSuite(Test),
|
unittest.makeSuite(Test),
|
||||||
DocFileSuite('README.txt', optionflags=flags),
|
DocFileSuite('README.txt', optionflags=flags),
|
||||||
DocFileSuite('crawl/README.txt', optionflags=flags),
|
DocFileSuite('crawl/README.txt', optionflags=flags),
|
||||||
DocFileSuite('crawl/Outlook.txt', optionflags=flags),
|
#DocFileSuite('crawl/outlook.txt', optionflags=flags),
|
||||||
))
|
))
|
||||||
return testSuite
|
return testSuite
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue