def cli(ctx, url, network): # initialize Client cl = Client(base_url=url, version='auto') # output version to show the connected succeeded v = cl.version() info('Connected to Docker {v[Version]}, api version ' '{v[ApiVersion]}.'.format(v=v)) # find frontend network nets = [n for n in cl.networks(names=[network]) if n['Name'] == network] assert len(nets) < 2 # WTF? if not nets: exit_err("Could not find a network name {!r}".format(network)) ctx.obj = {'cl': cl, 'network_name': network, 'network': nets[0]['Name']}