Skip to content

Commit

Permalink
Merge commit 'e8f292ba89fba6fb1731a1bb33aa5fb62e6ac829' into jinja
Browse files Browse the repository at this point in the history
Also restored builder.py file-endings to unix-style
(bad endings introduced in 9bb8857)

Conflicts:
	.gitignore
	buildbot/status/web/builder.py
  • Loading branch information
marcus-sonestedt committed Dec 12, 2009
2 parents 4730a52 + e8f292b commit f1e32c1
Show file tree
Hide file tree
Showing 16 changed files with 1,025 additions and 402 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -23,6 +23,7 @@ docs/images/overview.png
docs/images/slavebuilder.png
docs/images/slaves.png
docs/images/status.png
.stgit-edit.txt
.project
.pydevproject
.settings
87 changes: 33 additions & 54 deletions buildbot/slave/commands.py
@@ -1,6 +1,6 @@
# -*- test-case-name: buildbot.test.test_slavecommand -*-

import os, sys, re, signal, shutil, types, time
import os, sys, re, signal, shutil, types, time, tarfile, tempfile
from stat import ST_CTIME, ST_MTIME, ST_SIZE

from zope.interface import implements
Expand All @@ -11,6 +11,7 @@

from buildbot.slave.interfaces import ISlaveCommand
from buildbot.slave.registry import registerSlaveCommand
from buildbot.util import to_text

# this used to be a CVS $-style "Revision" auto-updated keyword, but since I
# moved to Darcs as the primary repository, this is updated manually each
Expand Down Expand Up @@ -66,7 +67,7 @@ def get_real(command):
if isinstance(elt, Obfuscated):
rv.append(elt.real)
else:
rv.append(elt)
rv.append(to_text(elt))
return rv
get_real = staticmethod(get_real)

Expand All @@ -78,7 +79,7 @@ def get_fake(command):
if isinstance(elt, Obfuscated):
rv.append(elt.fake)
else:
rv.append(elt)
rv.append(to_text(elt))
return rv
get_fake = staticmethod(get_fake)

Expand Down Expand Up @@ -307,6 +308,8 @@ def __init__(self, builder, command,
self.sendRC = sendRC
self.logfiles = logfiles
self.workdir = workdir
if not os.path.exists(workdir):
os.makedirs(workdir)
self.environ = os.environ.copy()
if environ:
if environ.has_key('PYTHONPATH'):
Expand Down Expand Up @@ -938,7 +941,7 @@ def finished(self, res):
registerSlaveCommand("uploadFile", SlaveFileUploadCommand, command_version)


class SlaveDirectoryUploadCommand(Command):
class SlaveDirectoryUploadCommand(SlaveFileUploadCommand):
"""
Upload a directory from slave to build master
Arguments:
Expand All @@ -964,63 +967,39 @@ def start(self):
if self.debug:
log.msg('SlaveDirectoryUploadCommand started')

# create some lists with all files and directories
foundFiles = []
foundDirs = []

self.baseRoot = os.path.join(self.builder.basedir,
self.workdir,
os.path.expanduser(self.dirname))
if self.debug:
log.msg("baseRoot: %r" % self.baseRoot)

for root, dirs, files in os.walk(self.baseRoot):
tempRoot = root
relRoot = ''
while (tempRoot != self.baseRoot):
tempRoot, tempRelRoot = os.path.split(tempRoot)
relRoot = os.path.join(tempRelRoot, relRoot)
for name in files:
foundFiles.append(os.path.join(relRoot, name))
for directory in dirs:
foundDirs.append(os.path.join(relRoot, directory))

self.path = os.path.join(self.builder.basedir,
self.workdir,
os.path.expanduser(self.dirname))
if self.debug:
log.msg("foundDirs: %s" % (str(foundDirs)))
log.msg("foundFiles: %s" % (str(foundFiles)))

# create all directories on the master, to catch also empty ones
for dirname in foundDirs:
dirname = dirname.split(os.path.sep)
self.writer.callRemote("createdir", dirname)

for filename in foundFiles:
self._writeFile(filename)
log.msg("path: %r" % self.path)

return None
# Create temporary archive
fd, self.tarname = tempfile.mkstemp()
fileobj = os.fdopen(fd, 'w')
archive = tarfile.open(name=self.tarname, mode="w|bz2", fileobj=fileobj)
archive.add(self.path, '')
archive.close()
fileobj.close()

def _writeFile(self, filename):
"""Write a file to the remote writer"""
# Transfer it
self.fp = open(self.tarname, 'rb')

log.msg("_writeFile: %r" % (filename))
self.writer.callRemote('open', filename.split(os.path.sep))
data = open(os.path.join(self.baseRoot, filename), "r").read()
self.writer.callRemote('write', data)
self.writer.callRemote('close')
return None
self.sendStatus({'header': "sending %s" % self.path})

def interrupt(self):
if self.debug:
log.msg('interrupted')
if self.interrupted:
return
if self.stderr is None:
self.stderr = 'Upload of %r interrupted' % self.path
self.rc = 1
self.interrupted = True
# the next _writeBlock call will notice the .interrupted flag
d = defer.Deferred()
reactor.callLater(0, self._loop, d)
def unpack(res):
# unpack the archive, but pass through any errors from _loop
d1 = self.writer.callRemote("unpack")
d1.addErrback(log.err)
d1.addCallback(lambda ignored: res)
return d1
d.addCallback(unpack)
d.addBoth(self.finished)
return d

def finished(self, res):
os.remove(self.tarname)
if self.debug:
log.msg('finished: stderr=%r, rc=%r' % (self.stderr, self.rc))
if self.stderr is None:
Expand Down
16 changes: 12 additions & 4 deletions buildbot/status/mail.py
Expand Up @@ -36,7 +36,7 @@ def message(attrs):
projectName - (str) Name of the project.
mode - (str) Mode set in MailNotifier. (failing, passing, problem).
mode - (str) Mode set in MailNotifier. (failing, passing, problem, change).
result - (str) Builder result as a string. 'success', 'warnings',
'failure', 'skipped', or 'exception'
Expand Down Expand Up @@ -87,7 +87,9 @@ def message(attrs):
text += "The Buildbot has detected a failed build"
elif attrs['mode'] == "passing":
text += "The Buildbot has detected a passing build"
else:
elif attrs['mode'] == "change" and attrs['result'] == 'success':
text += "The Buildbot has detected a restored build"
else:
text += "The Buildbot has detected a new failure"
text += " of %s on %s.\n" % (attrs['builderName'], attrs['projectName'])
if attrs['buildURL']:
Expand Down Expand Up @@ -214,6 +216,7 @@ def __init__(self, fromaddr, mode="all", categories=None, builders=None,
- 'passing': only send mail about builds which succeed
- 'problem': only send mail about a build which failed
when the previous build passed
- 'change': only send mail about builds who change status
@type builders: list of strings
@param builders: a list of builder names for which mail should be
Expand Down Expand Up @@ -258,7 +261,7 @@ def __init__(self, fromaddr, mode="all", categories=None, builders=None,
projectName - (str) Name of the project.
mode - (str) Mode set in MailNotifier. (failing, passing, problem).
mode - (str) Mode set in MailNotifier. (failing, passing, problem, change).
result - (str) Builder result as a string. 'success', 'warnings',
'failure', 'skipped', or 'exception'
Expand Down Expand Up @@ -317,7 +320,7 @@ def __init__(self, fromaddr, mode="all", categories=None, builders=None,
self.extraRecipients = extraRecipients
self.sendToInterestedUsers = sendToInterestedUsers
self.fromaddr = fromaddr
assert mode in ('all', 'failing', 'problem')
assert mode in ('all', 'failing', 'problem', 'change')
self.mode = mode
self.categories = categories
self.builders = builders
Expand Down Expand Up @@ -392,6 +395,11 @@ def buildFinished(self, name, build, results):
prev = build.getPreviousBuild()
if prev and prev.getResults() == FAILURE:
return
if self.mode == "change":
prev = build.getPreviousBuild()
if not prev or prev.getResults() == results:
print prev.getResults() if prev else "no prev"
return
# for testing purposes, buildMessage returns a Deferred that fires
# when the mail has been sent. To help unit tests, we return that
# Deferred here even though the normal IStatusReceiver.buildFinished
Expand Down

0 comments on commit f1e32c1

Please sign in to comment.