Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
try:
resp = requests.get(urljoin(self._endpoint, 'dashboard'),
headers=self._headers)
resp.raise_for_status()
except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError):
raise NeatoRobotException("Unable to refresh robots")
for robot in resp.json()['robots']:
if robot['mac_address'] is None:
continue # Ignore robots without mac-address
try:
self._robots.add(Robot(name=robot['name'],
vendor=self._vendor,
serial=robot['serial'],
secret=robot['secret_key'],
traits=robot['traits'],
endpoint=robot['nucleo_url']))
except NeatoRobotException:
print ("Your '{}' robot is offline.".format(robot['name']))
continue
self.refresh_persistent_maps()
for robot in self._robots:
robot.has_persistent_maps = robot.serial in self._persistent_maps