mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Refactor
This commit is contained in:
parent
c00de7b3c9
commit
a982b95846
1 changed files with 10 additions and 24 deletions
|
@ -203,34 +203,20 @@ except ImportError:
|
||||||
# httplib/http.client connection using unix domain socket
|
# httplib/http.client connection using unix domain socket
|
||||||
import socket
|
import socket
|
||||||
try:
|
try:
|
||||||
import httplib
|
from httplib import HTTPConnection
|
||||||
|
|
||||||
class UnixHTTPConnection(httplib.HTTPConnection):
|
|
||||||
def __init__(self, path, host='localhost', port=None, strict=None,
|
|
||||||
timeout=None):
|
|
||||||
httplib.HTTPConnection.__init__(self, host, port=port, strict=strict,
|
|
||||||
timeout=timeout)
|
|
||||||
self.path = path
|
|
||||||
|
|
||||||
def connect(self):
|
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
||||||
sock.connect(self.path)
|
|
||||||
self.sock = sock
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Python 3
|
# Python 3
|
||||||
import http.client
|
from http.client import HTTPConnection
|
||||||
|
|
||||||
class UnixHTTPConnection(http.client.HTTPConnection):
|
class UnixHTTPConnection(HTTPConnection):
|
||||||
def __init__(self, path, host='localhost', port=None,
|
def __init__(self, path, timeout=None):
|
||||||
timeout=None):
|
super(UnixHTTPConnection, self).__init__('localhost', timeout=timeout)
|
||||||
http.client.HTTPConnection.__init__(self, host, port=port,
|
self.path = path
|
||||||
timeout=timeout)
|
|
||||||
self.path = path
|
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
sock.connect(self.path)
|
sock.connect(self.path)
|
||||||
self.sock = sock
|
self.sock = sock
|
||||||
|
|
||||||
|
|
||||||
# LXD_ANSIBLE_STATES is a map of states that contain values of methods used
|
# LXD_ANSIBLE_STATES is a map of states that contain values of methods used
|
||||||
|
|
Loading…
Reference in a new issue