[Zope3-checkins] SVN: zdaemon/branches/py3/src/zdaemon/ Try to untangle bytes from strings.
Marius Gedminas
cvs-admin at zope.org
Thu Feb 14 11:15:50 UTC 2013
Log message for revision 129397:
Try to untangle bytes from strings.
Changed:
U zdaemon/branches/py3/src/zdaemon/tests/parent.py
U zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py
U zdaemon/branches/py3/src/zdaemon/zdctl.py
U zdaemon/branches/py3/src/zdaemon/zdrun.py
-=-
Modified: zdaemon/branches/py3/src/zdaemon/tests/parent.py
===================================================================
--- zdaemon/branches/py3/src/zdaemon/tests/parent.py 2013-02-14 11:15:47 UTC (rev 129396)
+++ zdaemon/branches/py3/src/zdaemon/tests/parent.py 2013-02-14 11:15:49 UTC (rev 129397)
@@ -19,7 +19,7 @@
zdrun = os.path.join(zctldir, 'zdrun.py')
donothing = os.path.join(tmp, 'donothing.sh')
fd = os.open(donothing, os.O_WRONLY|os.O_CREAT, 0o700)
- os.write(fd, donothing_contents)
+ os.write(fd, donothing_contents.encode())
os.close(fd)
args = [sys.executable, zdrun]
args += ['-d', '-b', '10', '-s', os.path.join(tmp, 'testsock'),
Modified: zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py
===================================================================
--- zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py 2013-02-14 11:15:47 UTC (rev 129396)
+++ zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py 2013-02-14 11:15:49 UTC (rev 129397)
@@ -423,9 +423,9 @@
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
sock.connect(sockname)
- sock.send(action + "\n")
+ sock.send(action.encode() + b"\n")
sock.shutdown(1) # We're not writing any more
- response = ""
+ response = b""
while 1:
data = sock.recv(1000)
if not data:
Modified: zdaemon/branches/py3/src/zdaemon/zdctl.py
===================================================================
--- zdaemon/branches/py3/src/zdaemon/zdctl.py 2013-02-14 11:15:47 UTC (rev 129396)
+++ zdaemon/branches/py3/src/zdaemon/zdctl.py 2013-02-14 11:15:49 UTC (rev 129397)
@@ -217,15 +217,15 @@
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
sock.connect(self.options.sockname)
- sock.send(action + "\n")
+ sock.send(action.encode() + b"\n")
sock.shutdown(1) # We're not writing any more
- response = ""
+ response = b""
while 1:
data = sock.recv(1000)
if not data:
break
response += data
- return response
+ return response.decode()
except socket.error as msg:
return None
finally:
Modified: zdaemon/branches/py3/src/zdaemon/zdrun.py
===================================================================
--- zdaemon/branches/py3/src/zdaemon/zdrun.py 2013-02-14 11:15:47 UTC (rev 129396)
+++ zdaemon/branches/py3/src/zdaemon/zdrun.py 2013-02-14 11:15:49 UTC (rev 129397)
@@ -282,8 +282,8 @@
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
s.connect(self.options.sockname)
- s.send("status\n")
- data = s.recv(1000)
+ s.send(b"status\n")
+ data = s.recv(1000).decode()
s.close()
except socket.error:
pass
@@ -470,7 +470,7 @@
self.commandsocket.close()
self.commandsocket = None
self.commandsocket, addr = self.mastersocket.accept()
- self.commandbuffer = ""
+ self.commandbuffer = b""
def dorecv(self):
data = self.commandsocket.recv(1000)
@@ -479,7 +479,7 @@
self.commandsocket.close()
self.commandsocket = None
self.commandbuffer += data
- if "\n" in self.commandbuffer:
+ if b"\n" in self.commandbuffer:
self.docommand()
self.commandsocket.close()
self.commandsocket = None
@@ -489,18 +489,18 @@
self.commandsocket = None
def docommand(self):
- lines = self.commandbuffer.split("\n")
+ lines = self.commandbuffer.split(b"\n")
args = lines[0].split()
if not args:
self.sendreply("Empty command")
return
- command = args[0]
+ command = args[0].decode()
methodname = "cmd_" + command
method = getattr(self, methodname, None)
if method:
- method(args)
+ method([a.decode() for a in args])
else:
- self.sendreply("Unknown command %r; 'help' for a list" % args[0])
+ self.sendreply("Unknown command %r; 'help' for a list" % command)
def cmd_start(self, args):
self.should_be_up = True
@@ -584,6 +584,7 @@
try:
if not msg.endswith("\n"):
msg = msg + "\n"
+ msg = msg.encode()
if hasattr(self.commandsocket, "sendall"):
self.commandsocket.sendall(msg)
else:
More information about the Zope3-Checkins
mailing list