Fix broken import in utilities.helper._accelerate (#27088)

* Fix py3 compatibility using six.moves.socketserver

* Remove useless call to str
This commit is contained in:
Pilou 2017-08-01 07:05:46 +02:00 committed by Toshio Kuratomi
parent 12e349fe48
commit 49b8bd0358
2 changed files with 6 additions and 7 deletions

View file

@ -92,7 +92,6 @@ import tempfile
import time import time
import traceback import traceback
import SocketServer
import datetime import datetime
from threading import Thread, Lock from threading import Thread, Lock
@ -100,6 +99,7 @@ from threading import Thread, Lock
# import module snippets # import module snippets
# we must import this here at the top so we can use get_module_path() # we must import this here at the top so we can use get_module_path()
from ansible.module_utils.basic import AnsibleModule, get_module_path from ansible.module_utils.basic import AnsibleModule, get_module_path
from ansible.module_utils.six.moves import socketserver
# the chunk size to read and send, assuming mtu 1500 and # the chunk size to read and send, assuming mtu 1500 and
# leaving room for base64 (+33%) encoding and header (100 bytes) # leaving room for base64 (+33%) encoding and header (100 bytes)
@ -285,7 +285,7 @@ class ThreadWithReturnValue(Thread):
Thread.join(self, timeout=timeout) Thread.join(self, timeout=timeout)
return self._return return self._return
class ThreadedTCPServer(SocketServer.ThreadingTCPServer): class ThreadedTCPServer(socketserver.ThreadingTCPServer):
key_list = [] key_list = []
last_event = datetime.datetime.now() last_event = datetime.datetime.now()
last_event_lock = Lock() last_event_lock = Lock()
@ -303,13 +303,13 @@ class ThreadedTCPServer(SocketServer.ThreadingTCPServer):
self.local_thread = LocalSocketThread(kwargs=dict(server=self)) self.local_thread = LocalSocketThread(kwargs=dict(server=self))
self.local_thread.start() self.local_thread.start()
SocketServer.ThreadingTCPServer.__init__(self, server_address, RequestHandlerClass) socketserver.ThreadingTCPServer.__init__(self, server_address, RequestHandlerClass)
def shutdown(self): def shutdown(self):
self.running = False self.running = False
SocketServer.ThreadingTCPServer.shutdown(self) socketserver.ThreadingTCPServer.shutdown(self)
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
# the key to use for this connection # the key to use for this connection
active_key = None active_key = None
@ -518,7 +518,7 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
fd.close() fd.close()
tb = traceback.format_exc() tb = traceback.format_exc()
log("failed to fetch the file: %s" % tb) log("failed to fetch the file: %s" % tb)
return dict(failed=True, stderr="Could not fetch the file: %s" % str(e)) return dict(failed=True, stderr="Could not fetch the file: %s" % e)
fd.close() fd.close()
return dict() return dict()

View file

@ -107,5 +107,4 @@ lib/ansible/modules/storage/infinidat/infini_fs.py
lib/ansible/modules/storage/infinidat/infini_host.py lib/ansible/modules/storage/infinidat/infini_host.py
lib/ansible/modules/storage/infinidat/infini_pool.py lib/ansible/modules/storage/infinidat/infini_pool.py
lib/ansible/modules/storage/infinidat/infini_vol.py lib/ansible/modules/storage/infinidat/infini_vol.py
lib/ansible/modules/utilities/helper/_accelerate.py
lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py