aboutsummaryrefslogtreecommitdiffstats
path: root/config.py
diff options
context:
space:
mode:
authorGravatar Christopher Baklid <[email protected]>2018-06-02 21:54:34 +0200
committerGravatar Christopher Baklid <[email protected]>2018-06-02 21:54:34 +0200
commit1798960f4e4029bffdc2d54ab904a1670e9c1659 (patch)
treefacf01616016e9740215831c909dd3ead2b85132 /config.py
parentupdate 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.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/config.py b/config.py
index bb18474..5a31013 100644
--- a/config.py
+++ b/config.py
@@ -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')