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' 1710518 - def __init__(self, command, 19 description=None, descriptionDone=None, 20 env=None, path=None, usePTY=0, 21 **kwargs):22 BuildStep.__init__(self, **kwargs) 23 self.addFactoryArguments(description=description, 24 descriptionDone=descriptionDone, 25 env=env, path=path, usePTY=usePTY, 26 command=command) 27 28 self.command=command 29 if description: 30 self.description = description 31 if isinstance(self.description, str): 32 self.description = [self.description] 33 if descriptionDone: 34 self.descriptionDone = descriptionDone 35 if isinstance(self.descriptionDone, str): 36 self.descriptionDone = [self.descriptionDone] 37 self.env=env 38 self.path=path 39 self.usePTY=usePTY4044 47 505452 self.step.stdio_log.addHeader("exit status %d\n" % status_object.value.exitCode) 53 self.step.processEnded(status_object)56 # render properties 57 properties = self.build.getProperties() 58 command = properties.render(self.command) 59 # set up argv 60 if type(command) in types.StringTypes: 61 if runtime.platformType == 'win32': 62 argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args 63 if '/c' not in argv: argv += ['/c'] 64 argv += [command] 65 else: 66 # for posix, use /bin/sh. for other non-posix, well, doesn't 67 # hurt to try 68 argv = ['/bin/sh', '-c', command] 69 else: 70 if runtime.platformType == 'win32': 71 argv = os.environ['COMSPEC'].split() # allow %COMSPEC% to have args 72 if '/c' not in argv: argv += ['/c'] 73 argv += list(command) 74 else: 75 argv = command 76 77 self.stdio_log = stdio_log = self.addLog("stdio") 78 79 if type(command) in types.StringTypes: 80 stdio_log.addHeader(command.strip() + "\n\n") 81 else: 82 stdio_log.addHeader(" ".join(command) + "\n\n") 83 stdio_log.addHeader("** RUNNING ON BUILDMASTER **\n") 84 stdio_log.addHeader(" in dir %s\n" % os.getcwd()) 85 stdio_log.addHeader(" argv: %s\n" % (argv,)) 86 self.step_status.setText(list(self.description)) 87 88 if self.env is None: 89 env = os.environ 90 else: 91 assert isinstance(self.env, dict) 92 env = self.env 93 # TODO add a timeout? 94 reactor.spawnProcess(self.LocalPP(self), argv[0], argv, 95 path=self.path, usePTY=self.usePTY, env=env )96 # (the LocalPP object will call processEnded for us) 9799 if status_object.value.exitCode != 0: 100 self.step_status.setText(["failed (%d)" % status_object.value.exitCode]) 101 self.finished(FAILURE) 102 else: 103 self.step_status.setText(list(self.descriptionDone)) 104 self.finished(SUCCESS)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Oct 29 10:00:45 2010 | http://epydoc.sourceforge.net |