* Fix python3 interpreter issue (#34811) * Update ansible.module_utils._text (#34811) * Convert to text later to account for multibyte characterspull/4420/head
parent
da3f7a8db1
commit
340064bfb9
|
@ -193,6 +193,7 @@ import time
|
||||||
from string import Template
|
from string import Template
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils._text import to_bytes, to_text
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_SOCKET_LOCATION = "/var/run/haproxy.sock"
|
DEFAULT_SOCKET_LOCATION = "/var/run/haproxy.sock"
|
||||||
|
@ -242,13 +243,16 @@ class HAProxy(object):
|
||||||
"""
|
"""
|
||||||
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
self.client.connect(self.socket)
|
self.client.connect(self.socket)
|
||||||
self.client.sendall('%s\n' % cmd)
|
self.client.sendall(to_bytes('%s\n' % cmd))
|
||||||
result = ''
|
|
||||||
buf = ''
|
result = b''
|
||||||
|
buf = b''
|
||||||
buf = self.client.recv(RECV_SIZE)
|
buf = self.client.recv(RECV_SIZE)
|
||||||
while buf:
|
while buf:
|
||||||
result += buf
|
result += buf
|
||||||
buf = self.client.recv(RECV_SIZE)
|
buf = self.client.recv(RECV_SIZE)
|
||||||
|
result = to_text(result, errors='surrogate_or_strict')
|
||||||
|
|
||||||
if capture_output:
|
if capture_output:
|
||||||
self.capture_command_output(cmd, result.strip())
|
self.capture_command_output(cmd, result.strip())
|
||||||
self.client.close()
|
self.client.close()
|
||||||
|
|
Loading…
Reference in New Issue