← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-processwithtimeout into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-processwithtimeout into launchpad:master.

Commit message:
Port ProcessWithTimeout to io.BytesIO

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/394741
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-processwithtimeout into launchpad:master.
diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py
index be6bb60..589c1f3 100644
--- a/lib/lp/buildmaster/interactor.py
+++ b/lib/lp/buildmaster/interactor.py
@@ -15,6 +15,7 @@ import sys
 import traceback
 
 from ampoule.pool import ProcessPool
+import six
 from six.moves.urllib.parse import urlparse
 import transaction
 from twisted.internet import (
@@ -389,7 +390,8 @@ class BuilderInteractor(object):
         def got_resume_bad(failure):
             stdout, stderr, code = failure.value
             raise CannotResumeHost(
-                "Resuming failed:\nOUT:\n%s\nERR:\n%s\n" % (stdout, stderr))
+                "Resuming failed:\nOUT:\n%s\nERR:\n%s\n" %
+                (six.ensure_str(stdout), six.ensure_str(stderr)))
 
         return d.addCallback(got_resume_ok).addErrback(got_resume_bad)
 
diff --git a/lib/lp/buildmaster/tests/test_interactor.py b/lib/lp/buildmaster/tests/test_interactor.py
index 0847014..c1f4c6d 100644
--- a/lib/lp/buildmaster/tests/test_interactor.py
+++ b/lib/lp/buildmaster/tests/test_interactor.py
@@ -16,6 +16,7 @@ import signal
 import tempfile
 
 from lpbuildd.builder import BuilderStatus
+import six
 from six.moves import xmlrpc_client
 from testtools.matchers import ContainsAll
 from testtools.testcase import ExpectedException
@@ -161,7 +162,7 @@ class TestBuilderInteractor(TestCase):
             url="http://crackle.ppa/";, virtualized=True, vm_host="pop"))
 
         def got_resume(output):
-            self.assertEqual(('snap crackle pop', ''), output)
+            self.assertEqual((b'snap crackle pop', b''), output)
         return d.addCallback(got_resume)
 
     def test_resumeSlaveHost_command_failed(self):
@@ -635,7 +636,7 @@ class TestSlave(TestCase):
         # XXX: JonathanLange 2010-09-23: We should instead pass the
         # expected vm_host into the client slave. Not doing this now,
         # since the SlaveHelper is being moved around.
-        self.assertEqual("%s\n" % slave._vm_host, out)
+        self.assertEqual("%s\n" % slave._vm_host, six.ensure_str(out))
 
     def test_resumeHost_failure(self):
         # On a failed resume, 'resumeHost' fires the returned deferred
diff --git a/lib/lp/services/twistedsupport/processmonitor.py b/lib/lp/services/twistedsupport/processmonitor.py
index 1dbbe98..c4f2b87 100644
--- a/lib/lp/services/twistedsupport/processmonitor.py
+++ b/lib/lp/services/twistedsupport/processmonitor.py
@@ -12,8 +12,8 @@ __all__ = [
     ]
 
 
+import io
 import os
-import StringIO
 
 from twisted.internet import (
     defer,
@@ -278,8 +278,8 @@ class ProcessWithTimeout(ProcessProtocol, TimeoutMixin):
         self._deferred = deferred
         self._clock = clock
         self._timeout = timeout
-        self._out_buf = StringIO.StringIO()
-        self._err_buf = StringIO.StringIO()
+        self._out_buf = io.BytesIO()
+        self._err_buf = io.BytesIO()
         self._process_transport = None
 
         # outReceived and errReceived are callback methods on