[Buildbot-commits] buildbot/buildbot/test runutils.py, 1.25, 1.26 test_vc.py, 1.84, 1.85
Brian Warner
warner at users.sourceforge.net
Sat Mar 22 22:14:19 UTC 2008
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20447/buildbot/test
Modified Files:
runutils.py test_vc.py
Log Message:
[project @ hush some pyflakes warnings, factor support code into test/runutils.py]
Original author: warner at lothar.com
Date: 2008-03-22 21:58:02+00:00
Index: runutils.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/runutils.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- runutils.py 20 Mar 2008 18:04:34 -0000 1.25
+++ runutils.py 22 Mar 2008 22:14:16 -0000 1.26
@@ -1,7 +1,8 @@
import signal
import shutil, os, errno
-from twisted.internet import defer, reactor
+from cStringIO import StringIO
+from twisted.internet import defer, reactor, protocol
from twisted.python import log, util
from buildbot import master, interfaces
@@ -13,6 +14,42 @@
from buildbot.sourcestamp import SourceStamp
from buildbot.status import builder
+
+
+class _PutEverythingGetter(protocol.ProcessProtocol):
+ def __init__(self, deferred, stdin):
+ self.deferred = deferred
+ self.outBuf = StringIO()
+ self.errBuf = StringIO()
+ self.outReceived = self.outBuf.write
+ self.errReceived = self.errBuf.write
+ self.stdin = stdin
+
+ def connectionMade(self):
+ if self.stdin is not None:
+ self.transport.write(self.stdin)
+ self.transport.closeStdin()
+
+ def processEnded(self, reason):
+ out = self.outBuf.getvalue()
+ err = self.errBuf.getvalue()
+ e = reason.value
+ code = e.exitCode
+ if e.signal:
+ self.deferred.errback((out, err, e.signal))
+ else:
+ self.deferred.callback((out, err, code))
+
+def myGetProcessOutputAndValue(executable, args=(), env={}, path='.',
+ _reactor_ignored=None, stdin=None):
+ """Like twisted.internet.utils.getProcessOutputAndValue but takes
+ stdin, too."""
+ d = defer.Deferred()
+ p = _PutEverythingGetter(d, stdin)
+ reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
+ return d
+
+
class MyBot(bot.Bot):
def remote_getSlaveInfo(self):
return self.parent.info
Index: test_vc.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_vc.py,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- test_vc.py 22 Mar 2008 22:14:12 -0000 1.84
+++ test_vc.py 22 Mar 2008 22:14:16 -0000 1.85
@@ -2,13 +2,12 @@
import sys, os, time, re
from email.Utils import mktime_tz, parsedate_tz
-from cStringIO import StringIO
from twisted.trial import unittest
from twisted.internet import defer, reactor, utils, protocol, task, error
from twisted.python import failure
from twisted.python.procutils import which
-from twisted.web import client
+from twisted.web import client, static, server
#defer.Deferred.debug = True
@@ -24,7 +23,7 @@
from buildbot.changes import changes
from buildbot.sourcestamp import SourceStamp
from buildbot.scripts import tryclient
-from buildbot.test.runutils import SignalMixin
+from buildbot.test.runutils import SignalMixin, myGetProcessOutputAndValue
#step.LoggedRemoteCommand.debug = True
@@ -53,41 +52,6 @@
# use a predetermined Internet-domain port number, unless we want to go
# all-out: bind the listen socket ourselves and pretend to be inetd.
-class _PutEverythingGetter(protocol.ProcessProtocol):
- def __init__(self, deferred, stdin):
- self.deferred = deferred
- self.outBuf = StringIO()
- self.errBuf = StringIO()
- self.outReceived = self.outBuf.write
- self.errReceived = self.errBuf.write
- self.stdin = stdin
-
- def connectionMade(self):
- if self.stdin is not None:
- self.transport.write(self.stdin)
- self.transport.closeStdin()
-
- def processEnded(self, reason):
- out = self.outBuf.getvalue()
- err = self.errBuf.getvalue()
- e = reason.value
- code = e.exitCode
- if e.signal:
- self.deferred.errback((out, err, e.signal))
- else:
- self.deferred.callback((out, err, code))
-
-def myGetProcessOutputAndValue(executable, args=(), env={}, path='.',
- reactor=None, stdin=None):
- """Like twisted.internet.utils.getProcessOutputAndValue but takes
- stdin, too."""
- if reactor is None:
- from twisted.internet import reactor
- d = defer.Deferred()
- p = _PutEverythingGetter(d, stdin)
- reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
- return d
-
config_vc = """
from buildbot.process import factory
from buildbot.steps import source
@@ -460,8 +424,6 @@
def serveHTTP(self):
# launch an HTTP server to serve the repository files
- from twisted.web import static, server
- from twisted.internet import reactor
self.root = static.File(self.helper.repbase)
self.site = server.Site(self.root)
self.httpServer = reactor.listenTCP(0, self.site)
More information about the Commits
mailing list