summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-10-02 12:00:47 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-10-02 13:09:32 +0000
commite0687d4f9014919dda15fa41b48d7ce8f6ffa401 (patch)
tree8b020e49277fdc870fbe34579f27067aad286df2
parent1f6ce63dde9d6601868d2c0fff6309fe20799917 (diff)
downloadmorph-e0687d4f9014919dda15fa41b48d7ce8f6ffa401.tar.gz
distbuild: base64-encode exec-output messages
JSON can only handle unicode strings, but commands can write anything to stdout/stderr, so let's base64 encode the data.
-rwxr-xr-xdistbuild-helper5
-rw-r--r--distbuild/build_controller.py7
-rw-r--r--distbuild/initiator.py5
3 files changed, 11 insertions, 6 deletions
diff --git a/distbuild-helper b/distbuild-helper
index cdc1873e..40e0f7e7 100755
--- a/distbuild-helper
+++ b/distbuild-helper
@@ -17,6 +17,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..
+import base64
import cliapp
import errno
import fcntl
@@ -231,8 +232,8 @@ class HelperMachine(distbuild.StateMachine):
msg = {
'type': 'exec-output',
'id': event.request_id,
- stream: data,
- other: '',
+ stream: base64.standard_b64encode(data),
+ other: base64.standard_b64encode(''),
}
logging.debug('JsonMachine: sent to parent: %s', repr(msg))
self.jm.send(msg)
diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py
index 93f97fac..898bcbc1 100644
--- a/distbuild/build_controller.py
+++ b/distbuild/build_controller.py
@@ -16,6 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..
+import base64
import logging
import httplib
import traceback
@@ -273,8 +274,10 @@ class BuildController(distbuild.StateMachine):
distbuild.crash_point()
if event.msg['id'] == self._helper_id:
- self._artifact_data.add(event.msg['stdout'])
- self._artifact_error.add(event.msg['stderr'])
+ self._artifact_data.add(
+ base64.standard_b64decode(event.msg['stdout']))
+ self._artifact_error.add(
+ base64.standard_b64decode(event.msg['stderr']))
def _maybe_finish_graph(self, event_source, event):
distbuild.crash_point()
diff --git a/distbuild/initiator.py b/distbuild/initiator.py
index b60700fd..a803c781 100644
--- a/distbuild/initiator.py
+++ b/distbuild/initiator.py
@@ -16,6 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..
+import base64
import cliapp
import logging
import random
@@ -145,8 +146,8 @@ class Initiator(distbuild.StateMachine):
step_name = msg['step_name']
if step_name in self._step_outputs:
f = self._step_outputs[step_name]
- f.write(msg['stdout'])
- f.write(msg['stderr'])
+ f.write(base64.standard_b64decode(msg['stdout']))
+ f.write(base64.standard_b64decode(msg['stderr']))
f.flush()
else:
logging.warning(