Accept base_url of None

This makes it very simple to get identical behaviour to the CLI:

    client = Client(os.environ.get('DOCKER_HOST'))
This commit is contained in:
Aanand Prasad 2014-01-14 17:19:39 +00:00
parent 96932fc1cb
commit 688554998a
1 changed files with 3 additions and 1 deletions

View File

@ -65,9 +65,11 @@ class APIError(requests.exceptions.HTTPError):
class Client(requests.Session):
def __init__(self, base_url="unix://var/run/docker.sock", version="1.6",
def __init__(self, base_url=None, version="1.6",
timeout=DEFAULT_TIMEOUT_SECONDS):
super(Client, self).__init__()
if base_url is None:
base_url = "unix://var/run/docker.sock"
if base_url.startswith('unix:///'):
base_url = base_url.replace('unix:/', 'unix:')
if base_url.startswith('tcp:'):