本文整理汇总了Python中buildbot.slave.commands.base.ShellCommand类的典型用法代码示例。如果您正苦于以下问题:Python ShellCommand类的具体用法?Python ShellCommand怎么用?Python ShellCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShellCommand类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSendNotimeout
def testSendNotimeout(self):
basedir = "test_slave_commands_base.logging.sendNotimeout"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir)
data = "x" * (ShellCommand.BUFFER_SIZE + 1)
s._addToBuffers('stdout', data)
self.failUnless(len(b.updates), 1)
示例2: testSendChunked
def testSendChunked(self):
basedir = "test_slave_commands_base.logging.sendBufferedChunked"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir)
data = "x" * ShellCommand.CHUNK_LIMIT * 2
s._addToBuffers('stdout', data)
s._sendBuffers()
self.failUnless(len(b.updates), 2)
示例3: testNoStderr
def testNoStderr(self):
basedir = "test_slave_commands_base.shellcommand.nostderr"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, [sys.executable, '-c', 'import sys; sys.stderr.write("hello\\n")'], basedir, sendStderr=False)
d = s.start()
def check(ign):
self.failIf({'stderr': 'hello\n'} in b.updates)
self.failUnless({'rc': 0} in b.updates)
d.addCallback(check)
return d
示例4: testNoStdout
def testNoStdout(self):
basedir = "test_slave_commands_base.shellcommand.nostdout"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir, sendStdout=False)
d = s.start()
def check(ign):
self.failIf({'stdout': 'hello\n'} in b.updates)
self.failUnless({'rc': 0} in b.updates)
d.addCallback(check)
return d
示例5: testNoLogEnviron
def testNoLogEnviron(self):
basedir = "test_slave_commands_base.shellcommand.start"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir, environ={"FOO": "BAR"}, logEnviron=False)
d = s.start()
def check(ign):
headers = "".join([update.values()[0] for update in b.updates if update.keys() == ["header"] ])
self.failUnless("FOO=BAR\n" not in headers)
d.addCallback(check)
return d
示例6: testUnsetEnvironVar
def testUnsetEnvironVar(self):
basedir = "test_slave_commands_base.shellcommand.start"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir, environ={"PATH":None})
d = s.start()
def check(ign):
headers = "".join([update.values()[0] for update in b.updates if update.keys() == ["header"] ])
self.failUnless(not re.match('\bPATH=',headers))
d.addCallback(check)
return d
示例7: testStringCommand
def testStringCommand(self):
basedir = "test_slave_commands_base.shellcommand.string"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, 'echo hello', basedir)
d = s.start()
def check(ign):
self.failUnless({'stdout': 'hello\n'} in b.updates)
self.failUnless({'rc': 0} in b.updates)
d.addCallback(check)
return d
示例8: testBadCommand
def testBadCommand(self):
basedir = "test_slave_commands_base.shellcommand.badcommand"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, ['command_that_doesnt_exist.exe'], basedir)
s.workdir = 1
d = s.start()
def check(err):
self.flushLoggedErrors()
err.trap(AbandonChain)
d.addBoth(check)
return d
示例9: testKeepStdout
def testKeepStdout(self):
basedir = "test_slave_commands_base.shellcommand.keepstdout"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir, keepStdout=True)
d = s.start()
def check(ign):
self.failUnless({'stdout': 'hello\n'} in b.updates)
self.failUnless({'rc': 0} in b.updates)
self.failUnlessEquals(s.stdout, 'hello\n')
d.addCallback(check)
return d
示例10: testCommandMaxTime
def testCommandMaxTime(self):
basedir = "test_slave_commands_base.shellcommand.maxtime"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, 'sleep 10; echo hello', basedir, maxTime=5)
clock = task.Clock()
s._reactor = clock
d = s.start()
def check(ign):
self.failUnless({'stdout': 'hello\n'} not in b.updates)
self.failUnless({'rc': -1} in b.updates, b.updates)
d.addCallback(check)
clock.advance(6)
return d
示例11: testEnvironExpandVar
def testEnvironExpandVar(self):
basedir = "test_slave_commands_base.shellcommand.start"
b = FakeSlaveBuilder(False, basedir)
environ = {"EXPND": "-${PATH}-",
"DOESNT_EXPAND": "-${---}-",
"DOESNT_FIND": "-${DOESNT_EXISTS}-"}
s = ShellCommand(b, stdoutCommand('hello'), basedir, environ=environ)
d = s.start()
def check(ign):
headers = "".join([update.values()[0] for update in b.updates if update.keys() == ["header"] ])
self.failUnless("EXPND=-$" not in headers)
self.failUnless("DOESNT_FIND=--\n" in headers)
self.failUnless("DOESNT_EXPAND=-${---}-\n" in headers)
d.addCallback(check)
return d
示例12: testSendBufferedInterleaved
def testSendBufferedInterleaved(self):
basedir = "test_slave_commands_base.logging.sendBufferedInterleaved"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir)
s._addToBuffers('stdout', 'hello ')
s._addToBuffers('stderr', 'DIEEEEEEE')
s._addToBuffers('stdout', 'world')
s._sendBuffers()
self.failUnlessEqual(b.updates, [
{'stdout': 'hello '},
{'stderr': 'DIEEEEEEE'},
{'stdout': 'world'},
])
示例13: testBadCommand
def testBadCommand(self):
basedir = "test_slave_commands_base.shellcommand.badcommand"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, ['command_that_doesnt_exist.exe'], basedir)
s.workdir = 1
d = s.start()
def check(err):
self.flushLoggedErrors()
err.trap(AbandonChain)
stderr = []
# Here we're checking that the exception starting up the command
# actually gets propogated back to the master.
for u in b.updates:
if 'stderr' in u:
stderr.append(u['stderr'])
stderr = "".join(stderr)
self.failUnless("TypeError" in stderr, stderr)
d.addBoth(check)
return d
示例14: testSendStatus
def testSendStatus(self):
basedir = "test_slave_commands_base.logging.sendStatus"
b = FakeSlaveBuilder(False, basedir)
s = ShellCommand(b, stdoutCommand('hello'), basedir)
s.sendStatus({'stdout': 'hello\n'})
self.failUnlessEqual(b.updates, [{'stdout': 'hello\n'}])