From 9650935184576b085dea095c541a5a7637a184c6 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 24 Feb 2008 15:11:05 +0000 Subject: [PATCH] work in progress: cybertools.agent - more on base and sample implementations git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2416 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/README.txt | 3 +++ agent/base/agent.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/agent/README.txt b/agent/README.txt index 6fd351a..481888b 100644 --- a/agent/README.txt +++ b/agent/README.txt @@ -154,6 +154,9 @@ is just one scheduler associated with the master agent. >>> master.scheduler +We schedule a sample job by taking the role of the controller and simply +call the master agent's callback method for entering jobs. + >>> from cybertools.agent.base.control import JobSpecification >>> jobSpec = JobSpecification('sample', agent='sample01') >>> master.setupJobs([jobSpec]) diff --git a/agent/base/agent.py b/agent/base/agent.py index 6fb4912..54ac3ef 100644 --- a/agent/base/agent.py +++ b/agent/base/agent.py @@ -81,7 +81,13 @@ class Master(Agent): class SampleAgent(Agent): def execute(self, job, params=None): - print 'Job %s on agent %s has been executed.' % (job, self) + msg = 'Job %s on agent %s has been executed.' % (job, self) + print msg + self.log(msg) + + def log(self, msg): + self.logger.log(dict(msg=msg)) + agents.register(SampleAgent, Master, name='sample')