Ignore nmap style issue - pylint bug

This commit is contained in:
Paulus Schoutsen 2015-10-08 21:45:51 -07:00
parent dc5f0ef314
commit 0624725e21

View file

@ -117,15 +117,18 @@ class NmapDeviceScanner(object):
scanner = PortScanner() scanner = PortScanner()
options = "-F --host-timeout 5" options = "-F --host-timeout 5"
exclude_targets = set()
if self.home_interval: if self.home_interval:
now = dt_util.now() boundary = dt_util.now() - self.home_interval
for host in self.last_results: last_results = [device for device in self.last_results
if host.last_update + self.home_interval > now: if device.last_update > boundary]
exclude_targets.add(host) if last_results:
if exclude_targets: # Pylint is confused here.
options += " --exclude {}".format(",".join(t.ip for t # pylint: disable=no-member
in exclude_targets)) options += " --exclude {}".format(",".join(device.ip for device
in last_results))
else:
last_results = []
try: try:
result = scanner.scan(hosts=self.hosts, arguments=options) result = scanner.scan(hosts=self.hosts, arguments=options)
@ -133,7 +136,6 @@ class NmapDeviceScanner(object):
return False return False
now = dt_util.now() now = dt_util.now()
self.last_results = []
for ipv4, info in result['scan'].items(): for ipv4, info in result['scan'].items():
if info['status']['state'] != 'up': if info['status']['state'] != 'up':
continue continue
@ -142,9 +144,9 @@ class NmapDeviceScanner(object):
mac = info['addresses'].get('mac') or _arp(ipv4) mac = info['addresses'].get('mac') or _arp(ipv4)
if mac is None: if mac is None:
continue continue
device = Device(mac.upper(), name, ipv4, now) last_results.append(Device(mac.upper(), name, ipv4, now))
self.last_results.append(device)
self.last_results.extend(exclude_targets) self.last_results = last_results
_LOGGER.info("nmap scan successful") _LOGGER.info("nmap scan successful")
return True return True