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
This commit is contained in:
		
							parent
							
								
									740fc05308
								
							
						
					
					
						commit
						70f92e90b0
					
				
					 1 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
					@ -39,6 +39,8 @@ class CmdlineController(SampleController):
 | 
				
			||||||
        prot = CmdlineProtocol()
 | 
					        prot = CmdlineProtocol()
 | 
				
			||||||
        prot.controller = self
 | 
					        prot.controller = self
 | 
				
			||||||
        stdio.StandardIO(prot)
 | 
					        stdio.StandardIO(prot)
 | 
				
			||||||
 | 
					        self.results = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
controllers.register(CmdlineController, Master, name='cmdline')
 | 
					controllers.register(CmdlineController, Master, name='cmdline')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,8 +82,8 @@ class CmdlineProtocol(basic.LineReceiver):
 | 
				
			||||||
                key, value = arg.split('=', 1)
 | 
					                key, value = arg.split('=', 1)
 | 
				
			||||||
                if value in ('True', 'False'):
 | 
					                if value in ('True', 'False'):
 | 
				
			||||||
                    value = eval(value)
 | 
					                    value = eval(value)
 | 
				
			||||||
                elif value.isdigit():
 | 
					                #elif value.isdigit():
 | 
				
			||||||
                    value = int(value)
 | 
					                #    value = int(value)
 | 
				
			||||||
                kwArgs[key] = value
 | 
					                kwArgs[key] = value
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                posArgs.append(arg)
 | 
					                posArgs.append(arg)
 | 
				
			||||||
| 
						 | 
					@ -97,6 +99,7 @@ class CmdlineProtocol(basic.LineReceiver):
 | 
				
			||||||
        self.transport.write('> ')
 | 
					        self.transport.write('> ')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_help(self, command=None):
 | 
					    def do_help(self, command=None):
 | 
				
			||||||
 | 
					        "Help"
 | 
				
			||||||
        if command:
 | 
					        if command:
 | 
				
			||||||
            self.sendLine(getattr(self, 'do_' + command).__doc__)
 | 
					            self.sendLine(getattr(self, 'do_' + command).__doc__)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -104,15 +107,22 @@ class CmdlineProtocol(basic.LineReceiver):
 | 
				
			||||||
            self.sendLine("Valid commands: " +" ".join(commands))
 | 
					            self.sendLine("Valid commands: " +" ".join(commands))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_shutdown(self):
 | 
					    def do_shutdown(self):
 | 
				
			||||||
 | 
					        "Shut down"
 | 
				
			||||||
        self.sendLine('Shutting down.')
 | 
					        self.sendLine('Shutting down.')
 | 
				
			||||||
        reactor.stop()
 | 
					        reactor.stop()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_agent(self, agentType, name):
 | 
					    def do_agent(self, agentType='crawl.filesystem', name='a1'):
 | 
				
			||||||
 | 
					        "Create agent"
 | 
				
			||||||
        self.controller.createAgent(agentType, name)
 | 
					        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)
 | 
					        self.controller.enterJob(jobType, agent, params=kw)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def do_showresult(self):
 | 
				
			||||||
 | 
					        "Show last result"
 | 
				
			||||||
 | 
					        print self.controller.result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TelnetProtocol(CmdlineProtocol):
 | 
					class TelnetProtocol(CmdlineProtocol):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue