From 740fc05308cd51ab15c796905ccf3e70423866ce Mon Sep 17 00:00:00 2001 From: helmutm Date: Wed, 21 May 2008 11:52:28 +0000 Subject: [PATCH] extend cmdline controller to handle simple agent and job specifications git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2612 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/control/cmdline.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/agent/control/cmdline.py b/agent/control/cmdline.py index 8e950c1..f56d08d 100644 --- a/agent/control/cmdline.py +++ b/agent/control/cmdline.py @@ -73,13 +73,25 @@ class CmdlineProtocol(basic.LineReceiver): commandParts = line.split() command = commandParts[0].lower() args = commandParts[1:] + posArgs = [] + kwArgs = {} + for arg in args: + if '=' in arg: # directory='...' + key, value = arg.split('=', 1) + if value in ('True', 'False'): + value = eval(value) + elif value.isdigit(): + value = int(value) + kwArgs[key] = value + else: + posArgs.append(arg) try: method = getattr(self, 'do_' + command) except AttributeError, e: self.sendLine('Error: no such command.') else: try: - method(*args) + method(*posArgs, **kwArgs) except Exception, e: self.sendLine('Error: ' + str(e)) self.transport.write('> ') @@ -95,6 +107,12 @@ class CmdlineProtocol(basic.LineReceiver): self.sendLine('Shutting down.') reactor.stop() + def do_agent(self, agentType, name): + self.controller.createAgent(agentType, name) + + def do_job(self, jobType, agent, **kw): + self.controller.enterJob(jobType, agent, params=kw) + class TelnetProtocol(CmdlineProtocol):