Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Virtualization:Tests
aexpect
0003-aexpect-Encode-decode-when-writing-to-buff...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-aexpect-Encode-decode-when-writing-to-buffer-like-ob.patch of Package aexpect
From 7ece383d85a5df2c924e837eadeb69d4640b1562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= <ldoktor@redhat.com> Date: Tue, 9 Aug 2016 09:24:57 +0200 Subject: [PATCH 02/10] aexpect: Encode/decode when writing to buffer-like object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The python3 does not support implicit encode/decoding from/to bytes, let's explicitly use encode/decode on such places. Signed-off-by: Lukáš Doktor <ldoktor@redhat.com> --- aexpect/client.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/aexpect/client.py b/aexpect/client.py index ff97036..f03340d 100644 --- a/aexpect/client.py +++ b/aexpect/client.py @@ -160,12 +160,13 @@ class Spawn(object): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # Send parameters to the server - sub.stdin.write("%s\n" % self.a_id) - sub.stdin.write("%s\n" % echo) - sub.stdin.write("%s\n" % ",".join(self.readers)) - sub.stdin.write("%s\n" % command) + sub.stdin.write(("%s\n" % self.a_id).encode()) + sub.stdin.write(("%s\n" % echo).encode()) + sub.stdin.write(("%s\n" % ",".join(self.readers)).encode()) + sub.stdin.write(("%s\n" % command).encode()) # Wait for the server to complete its initialization - while "Server %s ready" % self.a_id not in sub.stdout.readline(): + while ("Server %s ready" % self.a_id not in + sub.stdout.readline().decode()): pass # Open the reading pipes @@ -359,7 +360,7 @@ class Spawn(object): """ try: fd = os.open(self.inpipe_filename, os.O_RDWR) - os.write(fd, cont) + os.write(fd, cont.encode()) os.close(fd) except OSError: pass @@ -381,7 +382,7 @@ class Spawn(object): """ try: fd = os.open(self.ctrlpipe_filename, os.O_RDWR) - os.write(fd, "%10d%s" % (len(control_str), control_str)) + os.write(fd, ("%10d%s" % (len(control_str), control_str)).encode()) os.close(fd) except OSError: pass @@ -560,7 +561,7 @@ class Tail(Spawn): break if fd in r: # Some data is available; read it - new_data = os.read(fd, 1024) + new_data = os.read(fd, 1024).decode() if not new_data: break bfr += new_data @@ -683,7 +684,7 @@ class Expect(Tail): except (select.error, TypeError): return data if fd in r: - new_data = os.read(fd, 1024) + new_data = os.read(fd, 1024).decode() if not new_data: return data data += new_data -- 2.10.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor