python3 compatibility manager fix

develop
Timur Tuchkovenko 2015-02-27 00:10:32 +05:00
parent 5efe3f4593
commit 9fe12dfa83
1 changed files with 7 additions and 2 deletions

View File

@ -56,6 +56,7 @@ import sys
import os
import socket
import threading
from six import PY3
from six.moves import queue
import re
from types import *
@ -262,7 +263,7 @@ class Manager(object):
# lock the socket and send our command
try:
self._sock.write(command)
self._sock.write(command.encode('ascii'))
self._sock.flush()
except socket.error as e:
raise ManagerSocketException(e.errno, e.strerror)
@ -290,6 +291,7 @@ class Manager(object):
try:
lines = []
for line in self._sock:
line = line.decode('ascii')
# check to see if this is the greeting line
if not self.title and '/' in line and not ':' in line:
# store the title of the manager we are connecting to:
@ -452,6 +454,9 @@ class Manager(object):
try:
_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
_sock.connect((host, port))
if PY3:
self._sock = _sock.makefile(mode='rwb', buffering=0)
else:
self._sock = _sock.makefile()
_sock.close()
except socket.error as e: