From 49b8bd03580a732f32ec374846a4fe46f3df7c58 Mon Sep 17 00:00:00 2001 From: Pilou Date: Tue, 1 Aug 2017 07:05:46 +0200 Subject: [PATCH] Fix broken import in utilities.helper._accelerate (#27088) * Fix py3 compatibility using six.moves.socketserver * Remove useless call to str --- lib/ansible/modules/utilities/helper/_accelerate.py | 12 ++++++------ test/sanity/import/skip.txt | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/utilities/helper/_accelerate.py b/lib/ansible/modules/utilities/helper/_accelerate.py index 325b85f5cde..4df745dd480 100644 --- a/lib/ansible/modules/utilities/helper/_accelerate.py +++ b/lib/ansible/modules/utilities/helper/_accelerate.py @@ -92,7 +92,6 @@ import tempfile import time import traceback -import SocketServer import datetime from threading import Thread, Lock @@ -100,6 +99,7 @@ from threading import Thread, Lock # import module snippets # 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.six.moves import socketserver # the chunk size to read and send, assuming mtu 1500 and # leaving room for base64 (+33%) encoding and header (100 bytes) @@ -285,7 +285,7 @@ class ThreadWithReturnValue(Thread): Thread.join(self, timeout=timeout) return self._return -class ThreadedTCPServer(SocketServer.ThreadingTCPServer): +class ThreadedTCPServer(socketserver.ThreadingTCPServer): key_list = [] last_event = datetime.datetime.now() last_event_lock = Lock() @@ -303,13 +303,13 @@ class ThreadedTCPServer(SocketServer.ThreadingTCPServer): self.local_thread = LocalSocketThread(kwargs=dict(server=self)) self.local_thread.start() - SocketServer.ThreadingTCPServer.__init__(self, server_address, RequestHandlerClass) + socketserver.ThreadingTCPServer.__init__(self, server_address, RequestHandlerClass) def shutdown(self): 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 active_key = None @@ -518,7 +518,7 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): fd.close() tb = traceback.format_exc() 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() return dict() diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 1528c21e4f0..7a17a417562 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -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_pool.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