mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-26 18:58:54 +02:00
changed librouteros library name to avoid conflict with loaded library #2
This commit is contained in:
parent
10898768e3
commit
0896d0c991
8 changed files with 42 additions and 42 deletions
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
|
||||
|
||||
class LibRouterosError(Exception):
|
||||
"""Base exception for all other."""
|
||||
|
||||
|
||||
class ConnectionClosed(LibRouterosError):
|
||||
"""Raised when connection have been closed."""
|
||||
|
||||
|
||||
class ProtocolError(LibRouterosError):
|
||||
"""Raised when e.g. encoding/decoding fails."""
|
||||
|
||||
|
||||
class FatalError(ProtocolError):
|
||||
"""Exception raised when !fatal is received."""
|
||||
|
||||
|
||||
class TrapError(ProtocolError):
|
||||
"""
|
||||
Exception raised when !trap is received.
|
||||
|
||||
:param int category: Optional integer representing category.
|
||||
:param str message: Error message.
|
||||
"""
|
||||
|
||||
def __init__(self, message, category=None):
|
||||
self.category = category
|
||||
self.message = message
|
||||
super().__init__()
|
||||
|
||||
def __str__(self):
|
||||
return str(self.message.replace('\r\n', ','))
|
||||
|
||||
def __repr__(self):
|
||||
return '{}({!r})'.format(self.__class__.__name__, str(self))
|
||||
|
||||
|
||||
class MultiTrapError(ProtocolError):
|
||||
"""
|
||||
Exception raised when multiple !trap words have been received in one response.
|
||||
|
||||
:param traps: TrapError instances.
|
||||
"""
|
||||
|
||||
def __init__(self, *traps):
|
||||
self.traps = traps
|
||||
super().__init__()
|
||||
|
||||
def __str__(self):
|
||||
return ', '.join(str(trap) for trap in self.traps)
|
Loading…
Add table
Add a link
Reference in a new issue