Home | Trees | Indices | Help |
|
---|
|
1 import os, types 2 from twisted.python import runtime 3 from twisted.internet import reactor 4 from buildbot.process.buildstep import BuildStep 5 from buildbot.process.buildstep import SUCCESS, FAILURE 6 from twisted.internet.protocol import ProcessProtocol 79 """ 10 Run a shell command locally - on the buildmaster. The shell command 11 COMMAND is specified just as for a RemoteShellCommand. Note that extra 12 logfiles are not sopported. 13 """ 14 name='MasterShellCommand' 15 description='Running' 16 descriptionDone='Ran' 179421 BuildStep.__init__(self, **kwargs) 22 self.addFactoryArguments(description=description, 23 descriptionDone=descriptionDone, 24 command=command) 25 26 self.command=command 27 if description: 28 self.description = description 29 if isinstance(self.description, str): 30 self.description = [self.description] 31 if descriptionDone: 32 self.descriptionDone = descriptionDone 33 if isinstance(self.descriptionDone, str): 34 self.descriptionDone = [self.descriptionDone]3539 42 454947 self.step.stdio_log.addHeader("exit status %d\n" % status_object.value.exitCode) 48 self.step.processEnded(status_object)51 # render properties 52 properties = self.build.getProperties() 53 command = properties.render(self.command) 54 # set up argv 55 if type(command) in types.StringTypes: 56 if runtime.platformType == 'win32': 57 argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args 58 if '/c' not in argv: argv += ['/c'] 59 argv += [command] 60 else: 61 # for posix, use /bin/sh. for other non-posix, well, doesn't 62 # hurt to try 63 argv = ['/bin/sh', '-c', command] 64 else: 65 if runtime.platformType == 'win32': 66 argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args 67 if '/c' not in argv: argv += ['/c'] 68 argv += list(command) 69 else: 70 argv = command 71 72 self.stdio_log = stdio_log = self.addLog("stdio") 73 74 if type(command) in types.StringTypes: 75 stdio_log.addHeader(command.strip() + "\n\n") 76 else: 77 stdio_log.addHeader(" ".join(command) + "\n\n") 78 stdio_log.addHeader("** RUNNING ON BUILDMASTER **\n") 79 stdio_log.addHeader(" in dir %s\n" % os.getcwd()) 80 stdio_log.addHeader(" argv: %s\n" % (argv,)) 81 self.step_status.setText(list(self.description)) 82 83 # TODO add a timeout? 84 reactor.spawnProcess(self.LocalPP(self), argv[0], argv)85 # (the LocalPP object will call processEnded for us) 8688 if status_object.value.exitCode != 0: 89 self.step_status.setText(["failed (%d)" % status_object.value.exitCode]) 90 self.finished(FAILURE) 91 else: 92 self.step_status.setText(list(self.descriptionDone)) 93 self.finished(SUCCESS)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue May 25 17:53:18 2010 | http://epydoc.sourceforge.net |