diff options
| author | 2018-06-02 21:54:34 +0200 | |
|---|---|---|
| committer | 2018-06-02 21:54:34 +0200 | |
| commit | 1798960f4e4029bffdc2d54ab904a1670e9c1659 (patch) | |
| tree | facf01616016e9740215831c909dd3ead2b85132 /config.py | |
| parent | update readme [ci skip] (diff) | |
handle autodiscover better, find the python executable automatically, log errors not handled explicitly
Diffstat (limited to 'config.py')
| -rw-r--r-- | config.py | 22 | 
1 files changed, 15 insertions, 7 deletions
| @@ -1,18 +1,26 @@  import os - +import docker +from docker.errors import NotFound +import traceback  def autodiscover():      container_names = ["rmq", "pdrmq", "snekbox_pdrmq_1"] -    try: -        import docker -        client = docker.from_env() -        for name in container_names: + +    client = docker.from_env() +    for name in container_names: +        try:              container = client.containers.get(name)              if container.status == "running":                  host = list(container.attrs.get('NetworkSettings').get('Networks').values())[0]['IPAddress']                  return host -    except Exception: -        return '127.0.0.1' +        except NotFound: +            #print(traceback.format_exc()) +            print("retrying...") +            continue +        except Exception: +            print(traceback.format_exc()) +            return '127.0.0.1' +  USERNAME = os.environ.get('RMQ_USERNAME', 'guest') | 
