def remote_startCommand(self, stepref, stepId, command, args): """ This gets invoked by L{buildbot.process.step.RemoteCommand.start}, as part of various master-side BuildSteps, to start various commands that actually do the build. I return nothing. Eventually I will call .commandComplete() to notify the master-side RemoteCommand that I'm done. """ stepId = decode(stepId) command = decode(command) args = decode(args) self.activity() if self.command: log.msg("leftover command, dropping it") self.stopCommand() try: factory = registry.getFactory(command) except KeyError: raise UnknownCommand(u"unrecognized WorkerCommand '{0}'".format(command)) self.command = factory(self, stepId, args) log.msg(u" startCommand:{0} [id {1}]".format(command, stepId)) self.remoteStep = stepref self.remoteStep.notifyOnDisconnect(self.lostRemoteStep) d = self.command.doStart() d.addCallback(lambda res: None) d.addBoth(self.commandComplete) return None
def __init__(self, unicode_encoding, worker_basedir, builder_is_running, on_command_complete, on_lost_remote_step, command, command_id, args): self.unicode_encoding = unicode_encoding self.worker_basedir = worker_basedir self.builder_is_running = builder_is_running self.on_command_complete = on_command_complete self.on_lost_remote_step = on_lost_remote_step self.protocol_args_setup(command, args) try: factory = registry.getFactory(command) except KeyError: raise UnknownCommand( u"unrecognized WorkerCommand '{0}'".format(command)) # .command points to a WorkerCommand instance, and is set while the step is running. self.command = factory(self, command_id, args) self.is_complete = False
def test_all_commands_exist(self): # if this doesn't raise a KeyError, then we're good for n in registry.getAllCommandNames(): registry.getFactory(n)
def test_getFactory_KeyError(self): self.assertRaises(KeyError, lambda: registry.getFactory('nosuchcommand'))
def test_getFactory(self): factory = registry.getFactory('shell') self.assertEqual(factory, shell.WorkerShellCommand)
def test_getFactory_KeyError(self): with self.assertRaises(KeyError): registry.getFactory('nosuchcommand')