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 if type(self.command) in types.StringTypes:
40 if runtime.platformType == 'win32':
41 argv = os.environ['COMSPEC'].split()
42 if '/c' not in argv: argv += ['/c']
43 argv += [self.command]
44 else:
45
46
47 argv = ['/bin/sh', '-c', self.command]
48 else:
49 if runtime.platformType == 'win32':
50 argv = os.environ['COMSPEC'].split()
51 if '/c' not in argv: argv += ['/c']
52 argv += list(self.command)
53 else:
54 argv = self.command
55
56 self.stdio_log = stdio_log = self.addLog("stdio")
57
58 if type(self.command) in types.StringTypes:
59 stdio_log.addHeader(self.command.strip() + "\n\n")
60 else:
61 stdio_log.addHeader(" ".join(self.command) + "\n\n")
62 stdio_log.addHeader("** RUNNING ON BUILDMASTER **\n")
63 stdio_log.addHeader(" in dir %s\n" % os.getcwd())
64 stdio_log.addHeader(" argv: %s\n" % (argv,))
65
66
67 proc = reactor.spawnProcess(self.LocalPP(self), argv[0], argv)
68
69
77