Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #265 from Unity-Technologies/fixes/save-build-log
Browse files Browse the repository at this point in the history
Handle issues serializing messages and exclude custom files
  • Loading branch information
mariangemarcano authored Aug 3, 2017
2 parents 01a54fd + 9a5e498 commit ca2e887
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
10 changes: 8 additions & 2 deletions slave/buildslave/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,18 @@ def __init__(self, name, directory, rotateLength=1000000, defaultMode=None, maxR

def save(self, messages):
for message in messages:
json.dump(message, self)
self.write(os.linesep)
self.json_serialize(message)

self.flush()
self.handleFileRotation()

def json_serialize(self, message):
try:
json.dump(message, self)
self.write(os.linesep)
except:
log.err(failure.Failure(), "Failed to serialize message to json: " + str(message))

def write(self, data):
"""
Write some data to the file.
Expand Down
18 changes: 14 additions & 4 deletions slave/buildslave/runprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from collections import deque
from tempfile import NamedTemporaryFile

from twisted.python import runtime, log
from twisted.python import runtime, log, failure
from twisted.internet import reactor, defer, protocol, task, error

from buildslave import util
Expand Down Expand Up @@ -112,9 +112,13 @@ def _cleanupPoll(self, err):
self.poller = None

def stop(self):
self.poll()
if self.poller is not None:
self.poller.stop()
try:
self.poll()
if self.poller is not None:
self.poller.stop()
except:
log.err(failure.Failure(), 'LogFileWatcher failed to stop poller')

if self.started:
self.f.close()

Expand Down Expand Up @@ -651,6 +655,12 @@ def _sendBuffers(self):
logname, data, time = self.buffered.popleft()
self.builder.saveCommandOutputToLog(data, time)


# exclude saving the output from custom logfiles/artifacts
is_custom_log = isinstance(logname, tuple) and 'log' in logname # exclude custom configured files
if not self.logfiles or not is_custom_log:
self.builder.saveCommandOutputToLog(data, time)

# If this log is different than the last one, then we have to send
# out the message so far. This is because the message is
# transferred as a dictionary, which makes the ordering of keys
Expand Down

0 comments on commit ca2e887

Please sign in to comment.