1 import os, types
2 from twisted.python import log, failure, runtime
3 from twisted.internet import reactor, defer, task
4 from buildbot.process.buildstep import RemoteCommand, BuildStep
5 from buildbot.process.buildstep import SUCCESS, FAILURE
6 from twisted.internet.protocol import ProcessProtocol
7
9 """
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'
17
22
36
38
39 properties = self.build.getProperties()
40 command = properties.render(self.command)
41
42 if type(command) in types.StringTypes:
43 if runtime.platformType == 'win32':
44 argv = os.environ['COMSPEC'].split()
45 if '/c' not in argv: argv += ['/c']
46 argv += [command]
47 else:
48
49
50 argv = ['/bin/sh', '-c', command]
51 else:
52 if runtime.platformType == 'win32':
53 argv = os.environ['COMSPEC'].split()
54 if '/c' not in argv: argv += ['/c']
55 argv += list(command)
56 else:
57 argv = command
58
59 self.stdio_log = stdio_log = self.addLog("stdio")
60
61 if type(command) in types.StringTypes:
62 stdio_log.addHeader(command.strip() + "\n\n")
63 else:
64 stdio_log.addHeader(" ".join(command) + "\n\n")
65 stdio_log.addHeader("** RUNNING ON BUILDMASTER **\n")
66 stdio_log.addHeader(" in dir %s\n" % os.getcwd())
67 stdio_log.addHeader(" argv: %s\n" % (argv,))
68
69
70 proc = reactor.spawnProcess(self.LocalPP(self), argv[0], argv)
71
72
80