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