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
This commit is contained in:
parent
18f29f8d9a
commit
740fc05308
1 changed files with 19 additions and 1 deletions
|
@ -73,13 +73,25 @@ class CmdlineProtocol(basic.LineReceiver):
|
||||||
commandParts = line.split()
|
commandParts = line.split()
|
||||||
command = commandParts[0].lower()
|
command = commandParts[0].lower()
|
||||||
args = commandParts[1:]
|
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:
|
try:
|
||||||
method = getattr(self, 'do_' + command)
|
method = getattr(self, 'do_' + command)
|
||||||
except AttributeError, e:
|
except AttributeError, e:
|
||||||
self.sendLine('Error: no such command.')
|
self.sendLine('Error: no such command.')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
method(*args)
|
method(*posArgs, **kwArgs)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.sendLine('Error: ' + str(e))
|
self.sendLine('Error: ' + str(e))
|
||||||
self.transport.write('> ')
|
self.transport.write('> ')
|
||||||
|
@ -95,6 +107,12 @@ class CmdlineProtocol(basic.LineReceiver):
|
||||||
self.sendLine('Shutting down.')
|
self.sendLine('Shutting down.')
|
||||||
reactor.stop()
|
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):
|
class TelnetProtocol(CmdlineProtocol):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue