From 4d8f1e7cf14ae6ba329f35af4a1501db4ef3b5dc Mon Sep 17 00:00:00 2001 From: helmutm Date: Thu, 3 Apr 2008 11:17:37 +0000 Subject: [PATCH] keep state information with jobs; provide feedback to master and controller via 'inform()' methods git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2493 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/README.txt | 8 ++++++-- agent/base/control.py | 5 +++++ agent/crawl/README.txt | 2 +- agent/crawl/mail.py | 4 ---- agent/interfaces.py | 1 - 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/agent/README.txt b/agent/README.txt index d927a34..63c66cd 100644 --- a/agent/README.txt +++ b/agent/README.txt @@ -156,10 +156,13 @@ is just one scheduler associated with the master agent. We schedule a sample job by calling an internal method of the agent's -controller. +controller. In addition to the output of the job execution itself we +also get a note from the controller about the feedback it received +about the outcome of the job execution. >>> master.controllers[0].enterJob('sample', 'sample01') Job 00001 on agent sample01 has been executed. + Job 00001 completed; result: None; Logging ------- @@ -174,6 +177,7 @@ Logging >>> master.controllers[0].enterJob('sample', 'sample01') Job 00002 on agent sample01 has been executed. 2... agent:sample01 job:00002 message:job execution result:OK + Job 00002 completed; result: None; >>> for r in master.logger.records: ... print r @@ -214,4 +218,4 @@ the ``iterate()`` method provided for testing. >>> from cybertools.agent.tests import tester >>> tester.iterate() Job 00001 on agent sample01 has been executed. - + Job 00001 completed; result: Done; diff --git a/agent/base/control.py b/agent/base/control.py index 6c6ee0e..481818f 100644 --- a/agent/base/control.py +++ b/agent/base/control.py @@ -56,6 +56,11 @@ class SampleController(Controller): agents = (('sample01', 'base.sample'),) + def inform(self, identifier, state, result=None, message=''): + msg = ('Job %s %s; result: %s; %s' % + (identifier, state, result, message)) + print msg + def _getAgents(self): return [AgentSpecification(name, type) for name, type in self.agents] diff --git a/agent/crawl/README.txt b/agent/crawl/README.txt index dc13de2..6b194bd 100644 --- a/agent/crawl/README.txt +++ b/agent/crawl/README.txt @@ -43,4 +43,4 @@ the twisted reactor first. >>> from cybertools.agent.tests import tester >>> tester.iterate() SampleCrawler is collecting. - + Job 00001 completed; result: []; diff --git a/agent/crawl/mail.py b/agent/crawl/mail.py index 78b64c9..e1cf2cf 100644 --- a/agent/crawl/mail.py +++ b/agent/crawl/mail.py @@ -56,7 +56,3 @@ class MailCrawler(Crawler): def login(self): pass -#would it make sense to register this one at the AdapterFactory? -#or should it also just serve as base class for OutlookCrawler -#KMailCrawler etc. ? -#agents.register(MailCrawler, Agent, name='crawl.mail') \ No newline at end of file diff --git a/agent/interfaces.py b/agent/interfaces.py index c65f2e7..d5a5b0a 100644 --- a/agent/interfaces.py +++ b/agent/interfaces.py @@ -97,7 +97,6 @@ class IMaster(IAgent): def inform(job, result=None, message=''): """ Callback for informing the master about the state of a job. - The result is an IResource object (if not None). """