From 25e9db9935aa91657de47b99148b17039601e72c Mon Sep 17 00:00:00 2001 From: Chris AtLee Date: Mon, 17 May 2010 13:20:24 -0400 Subject: [PATCH] Do command arg encoding on the slave --- buildbot/slave/bot.py | 9 ++++++--- buildbot/slave/commands/base.py | 7 +++++++ buildbot/steps/shell.py | 6 ------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/buildbot/slave/bot.py b/buildbot/slave/bot.py index e2dbabb8c8a..5127cdcf9b6 100644 --- a/buildbot/slave/bot.py +++ b/buildbot/slave/bot.py @@ -1,5 +1,6 @@ import os.path +import sys import buildbot @@ -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): @@ -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 @@ -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: diff --git a/buildbot/slave/commands/base.py b/buildbot/slave/commands/base.py index 47be4759617..a509406fa12 100644 --- a/buildbot/slave/commands/base.py +++ b/buildbot/slave/commands/base.py @@ -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 diff --git a/buildbot/steps/shell.py b/buildbot/steps/shell.py index 3a804dd525f..ab82036cdc0 100644 --- a/buildbot/steps/shell.py +++ b/buildbot/steps/shell.py @@ -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