From ca0df7c33c3841a76344d392c68bce2593b2e989 Mon Sep 17 00:00:00 2001 From: Difrex Date: Tue, 9 Aug 2016 15:23:32 +0300 Subject: [PATCH] PEP8 --- surok/discovery.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/surok/discovery.py b/surok/discovery.py index f4a6ff4..4090213 100644 --- a/surok/discovery.py +++ b/surok/discovery.py @@ -1,5 +1,8 @@ import dns.resolver + +# Resolve service from mesos-dns SRV record +# return dict {"servicename": [{"name": "service.f.q.d.n", "port": 9999}]} def resolve(app, conf): hosts = {} services = app['services'] @@ -7,12 +10,17 @@ def resolve(app, conf): for service in services: hosts[service['name']] = [] try: - for rdata in dns.resolver.query('_' + service['name'] + '.' + service['group'] + '._tcp.' + domain, 'SRV'): + for rdata in dns.resolver.query('_' + + service['name'] + '.' + + service['group'] + '._tcp.' + + domain, 'SRV'): info = str(rdata).split() - server = { 'name': info[3], 'port': info[2] } + server = {'name': info[3], 'port': info[2]} - hosts[ service['name'] ].append(server) + hosts[service['name']].append(server) except Exception as e: - print("Could not resolve " + service['name'] + '.' + service['group'] + '._tcp.' + domain) + print(str(e) + ": Could not resolve " + + service['name'] + '.' + + service['group'] + '._tcp.' + domain) return hosts