From 70f92e90b03a2a3851856c137c65750d8c172b0c Mon Sep 17 00:00:00 2001 From: helmutm Date: Fri, 23 May 2008 10:19:25 +0000 Subject: [PATCH] work in progress: extend and improve commandline controller git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2613 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/control/cmdline.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/agent/control/cmdline.py b/agent/control/cmdline.py index f56d08d..4fee24e 100644 --- a/agent/control/cmdline.py +++ b/agent/control/cmdline.py @@ -39,6 +39,8 @@ class CmdlineController(SampleController): prot = CmdlineProtocol() prot.controller = self stdio.StandardIO(prot) + self.results = {} + controllers.register(CmdlineController, Master, name='cmdline') @@ -80,8 +82,8 @@ class CmdlineProtocol(basic.LineReceiver): key, value = arg.split('=', 1) if value in ('True', 'False'): value = eval(value) - elif value.isdigit(): - value = int(value) + #elif value.isdigit(): + # value = int(value) kwArgs[key] = value else: posArgs.append(arg) @@ -97,6 +99,7 @@ class CmdlineProtocol(basic.LineReceiver): self.transport.write('> ') def do_help(self, command=None): + "Help" if command: self.sendLine(getattr(self, 'do_' + command).__doc__) else: @@ -104,15 +107,22 @@ class CmdlineProtocol(basic.LineReceiver): self.sendLine("Valid commands: " +" ".join(commands)) def do_shutdown(self): + "Shut down" self.sendLine('Shutting down.') reactor.stop() - def do_agent(self, agentType, name): + def do_agent(self, agentType='crawl.filesystem', name='a1'): + "Create agent" self.controller.createAgent(agentType, name) - def do_job(self, jobType, agent, **kw): + def do_job(self, jobType='sample', agent='a1', **kw): + "Enter job" self.controller.enterJob(jobType, agent, params=kw) + def do_showresult(self): + "Show last result" + print self.controller.result + class TelnetProtocol(CmdlineProtocol):