Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _raise_if_closed(self):
if not self.opened:
raise napalm.base.exceptions.ConnectionClosedException("connection closed")
def _send_command(self, command):
"""Wrapper for self.device.send.command().
If command is a list will iterate through commands until valid command.
"""
try:
if isinstance(command, list):
for cmd in command:
output = self.device.send_command(cmd)
if "Invalid input: " not in output:
break
else:
output = self.device.send_command(command)
return output
except (socket.error, EOFError) as e:
raise ConnectionClosedException(str(e))
def _send_command(self, command):
"""Wrapper for self.device.send.command().
If command is a list will iterate through commands until valid command.
"""
try:
if isinstance(command, list):
for cmd in command:
output = self.device.send_command(cmd)
if "% Invalid" not in output:
break
else:
output = self.device.send_command(command)
return self._send_command_postprocess(output)
except (socket.error, EOFError) as e:
raise ConnectionClosedException(str(e))
def _send_command(self, command):
"""Wrapper for self.device.send.command().
If command is a list will iterate through commands until valid command.
"""
try:
if isinstance(command, list):
for cmd in command:
output = self.device.send_command(cmd)
if "% Invalid" not in output:
break
else:
output = self.device.send_command(command)
return self._send_command_postprocess(output)
except (socket.error, EOFError) as e:
raise ConnectionClosedException(str(e))