Skip to content
Snippets Groups Projects
Commit 44afd145 authored by Erik Reid's avatar Erik Reid
Browse files

pep8

parent 370c720d
No related branches found
No related tags found
No related merge requests found
......@@ -427,8 +427,10 @@ def _find_subnet_keys(addresses):
interface = ipaddress.ip_interface(m.group(1))
try:
matched_address = next(a for a, v in remaining_addresses.items()
if v == interface.ip)
matched_address = next(
a for a, v
in remaining_addresses.items()
if v == interface.ip)
del remaining_addresses[matched_address]
yield k, matched_address
except StopIteration:
......@@ -455,7 +457,7 @@ def _get_subnet_interfaces(address, r):
_subnet_lookup_semaphore.acquire()
try:
all_subnets = _get_subnets(r)
except:
except Exception:
logger.exception('error looking up subnets')
all_subnets = {}
finally:
......@@ -473,8 +475,18 @@ def _get_subnet_interfaces(address, r):
yield from json.loads(value.decode('utf-8'))
def _get_services_for_address(address: str, r: 'StrictRedis'):
def _get_services_for_address(address: str, r):
"""
match this address against all interfaces, then look up
any known services for that port
address is assumed to be in a valid v4/v6 format (it's used to
construct a ipaddress.ip_address object without try/except)
:param address: ip address string
:param r: a Redis instance
:return: yields PEERING_ADDRESS_SERVICES_LIST elements
"""
def _formatted_service(s):
return {
'id': s['id'],
......@@ -532,7 +544,9 @@ def _load_address_services_proc(address_queue, results_queue, config_params):
except json.JSONDecodeError:
logger.exception(f'error decoding redis entry for {address}')
except:
except Exception:
# just log info about this error (for debugging only)
# ... and quit (i.e. let finally cleanup)
logger.exception(f'error looking up service info for {address}')
finally:
# contract is to return None when finished
......
......@@ -20,6 +20,8 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
"test",
"data"))
_bootstrap_semaphore = threading.Semaphore()
@pytest.fixture
def data_config_filename():
......@@ -86,17 +88,6 @@ def data_config(data_config_filename):
return config.load(f)
TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
inventory_provider.__path__[0],
"..",
"test",
"data"))
_bootstrap_semaphore = threading.Semaphore()
class MockedRedis(object):
db = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment