Skip to content

Commit

Permalink
Do command arg encoding on the slave
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris AtLee committed May 17, 2010
1 parent 97499b1 commit 25e9db9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 6 additions & 3 deletions buildbot/slave/bot.py
@@ -1,5 +1,6 @@

import os.path
import sys

import buildbot

Expand Down Expand Up @@ -265,11 +266,12 @@ class Bot(pb.Referenceable, service.MultiService):
usePTY = None
name = "bot"

def __init__(self, basedir, usePTY, not_really=0):
def __init__(self, basedir, usePTY, not_really=0, unicode_encoding=None):
service.MultiService.__init__(self)
self.basedir = basedir
self.usePTY = usePTY
self.not_really = not_really
self.unicode_encoding = unicode_encoding or sys.getfilesystemencoding() or 'ascii'
self.builders = {}

def startService(self):
Expand Down Expand Up @@ -299,6 +301,7 @@ def remote_setBuilderList(self, wanted):
else:
b = SlaveBuilder(name, self.not_really)
b.usePTY = self.usePTY
b.unicode_encoding = self.unicode_encoding
b.setServiceParent(self)
b.setBuilddir(builddir)
self.builders[name] = b
Expand Down Expand Up @@ -476,11 +479,11 @@ class BuildSlave(service.MultiService):

def __init__(self, buildmaster_host, port, name, passwd, basedir,
keepalive, usePTY, keepaliveTimeout=30, umask=None,
maxdelay=300, debugOpts={}):
maxdelay=300, debugOpts={}, unicode_encoding=None):
log.msg("Creating BuildSlave -- buildbot.version: %s" % buildbot.version)
service.MultiService.__init__(self)
self.debugOpts = debugOpts.copy()
bot = self.botClass(basedir, usePTY)
bot = self.botClass(basedir, usePTY, unicode_encoding=unicode_encoding)
bot.setServiceParent(self)
self.bot = bot
if keepalive == 0:
Expand Down
7 changes: 7 additions & 0 deletions buildbot/slave/commands/base.py
Expand Up @@ -283,6 +283,13 @@ def __init__(self, builder, command,

self.builder = builder
self.command = Obfuscated.get_real(command)
if isinstance(self.command, (tuple, list)):
for i, a in enumerate(self.command):
if isinstance(a, unicode):
self.command[i] = a.encode(self.builder.unicode_encoding)
elif isinstance(self.command, unicode):
self.command = self.command.encode(self.builder.unicode_encoding)

self.fake_command = Obfuscated.get_fake(command)
self.sendStdout = sendStdout
self.sendStderr = sendStderr
Expand Down
6 changes: 0 additions & 6 deletions buildbot/steps/shell.py
Expand Up @@ -209,12 +209,6 @@ def start(self):
# create the actual RemoteShellCommand instance now
kwargs = properties.render(self.remote_kwargs)
command = properties.render(self.command)
if isinstance(command, unicode):
command = command.encode("utf-8")
elif not isinstance(command, str):
for i, a in enumerate(command):
if isinstance(a, unicode):
command[i] = a.encode("utf-8")
kwargs['command'] = command
kwargs['logfiles'] = self.logfiles

Expand Down

0 comments on commit 25e9db9

Please sign in to comment.