summaryrefslogtreecommitdiff
path: root/pysnmp/carrier
diff options
context:
space:
mode:
authorelie <elie>2015-10-17 09:54:53 +0000
committerelie <elie>2015-10-17 09:54:53 +0000
commit71dd5565a4b2948237a87319b57c565e18605761 (patch)
tree8bec49290752914dba279407b20a4bab26e61af3 /pysnmp/carrier
parentcd527959f8b5a98c577c9a431415e4fb67b4df95 (diff)
downloadpysnmp-git-71dd5565a4b2948237a87319b57c565e18605761.tar.gz
linted for trailing whitespaces
Diffstat (limited to 'pysnmp/carrier')
-rw-r--r--pysnmp/carrier/asyncio/base.py18
-rw-r--r--pysnmp/carrier/asyncio/dgram/base.py18
-rw-r--r--pysnmp/carrier/asyncio/dgram/udp.py19
-rw-r--r--pysnmp/carrier/asyncio/dgram/udp6.py1
-rw-r--r--pysnmp/carrier/asyncio/dispatch.py18
-rw-r--r--pysnmp/carrier/asyncore/base.py20
-rw-r--r--pysnmp/carrier/asyncore/dgram/base.py6
-rw-r--r--pysnmp/carrier/asyncore/dgram/udp6.py15
-rw-r--r--pysnmp/carrier/asyncore/dispatch.py11
-rw-r--r--pysnmp/carrier/base.py51
-rw-r--r--pysnmp/carrier/sockmsg.py21
-rw-r--r--pysnmp/carrier/twisted/dgram/base.py2
-rw-r--r--pysnmp/carrier/twisted/dgram/udp.py2
-rw-r--r--pysnmp/carrier/twisted/dgram/unix.py4
14 files changed, 109 insertions, 97 deletions
diff --git a/pysnmp/carrier/asyncio/base.py b/pysnmp/carrier/asyncio/base.py
index 200889b1..08902ed8 100644
--- a/pysnmp/carrier/asyncio/base.py
+++ b/pysnmp/carrier/asyncio/base.py
@@ -3,26 +3,26 @@
# Authors: Matt Hooks <me@matthooks.com>
# Zachary Lorusso <zlorusso@gmail.com>
#
-# Redistribution and use in source and binary forms, with or without
+# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
+# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
from pysnmp.carrier.asyncio.dispatch import AsyncioDispatcher
diff --git a/pysnmp/carrier/asyncio/dgram/base.py b/pysnmp/carrier/asyncio/dgram/base.py
index a37aa262..2052b442 100644
--- a/pysnmp/carrier/asyncio/dgram/base.py
+++ b/pysnmp/carrier/asyncio/dgram/base.py
@@ -3,26 +3,26 @@
# Authors: Matt Hooks <me@matthooks.com>
# Zachary Lorusso <zlorusso@gmail.com>
#
-# Redistribution and use in source and binary forms, with or without
+# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
+# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
import sys
diff --git a/pysnmp/carrier/asyncio/dgram/udp.py b/pysnmp/carrier/asyncio/dgram/udp.py
index 653c83c4..0470d1b2 100644
--- a/pysnmp/carrier/asyncio/dgram/udp.py
+++ b/pysnmp/carrier/asyncio/dgram/udp.py
@@ -3,32 +3,31 @@
# Authors: Matt Hooks <me@matthooks.com>
# Zachary Lorusso <zlorusso@gmail.com>
#
-# Redistribution and use in source and binary forms, with or without
+# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
+# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
import socket
from pysnmp.carrier.base import AbstractTransportAddress
from pysnmp.carrier.asyncio.dgram.base import DgramAsyncioProtocol
-from pysnmp.carrier import error
try:
import asyncio
except ImportError:
diff --git a/pysnmp/carrier/asyncio/dgram/udp6.py b/pysnmp/carrier/asyncio/dgram/udp6.py
index 8d791741..63800112 100644
--- a/pysnmp/carrier/asyncio/dgram/udp6.py
+++ b/pysnmp/carrier/asyncio/dgram/udp6.py
@@ -1,7 +1,6 @@
import socket
from pysnmp.carrier.base import AbstractTransportAddress
from pysnmp.carrier.asyncio.dgram.base import DgramAsyncioProtocol
-from pysnmp.carrier import error
try:
import asyncio
except ImportError:
diff --git a/pysnmp/carrier/asyncio/dispatch.py b/pysnmp/carrier/asyncio/dispatch.py
index 3886a44a..ca96683e 100644
--- a/pysnmp/carrier/asyncio/dispatch.py
+++ b/pysnmp/carrier/asyncio/dispatch.py
@@ -3,26 +3,26 @@
# Authors: Matt Hooks <me@matthooks.com>
# Zachary Lorusso <zlorusso@gmail.com>
#
-# Redistribution and use in source and binary forms, with or without
+# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
+# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
import sys
diff --git a/pysnmp/carrier/asyncore/base.py b/pysnmp/carrier/asyncore/base.py
index bee6ca6b..006ca6ea 100644
--- a/pysnmp/carrier/asyncore/base.py
+++ b/pysnmp/carrier/asyncore/base.py
@@ -9,7 +9,8 @@ from pysnmp import debug
class AbstractSocketTransport(asyncore.dispatcher, AbstractTransport):
protoTransportDispatcher = AsyncoreDispatcher
sockFamily = sockType = None
- retryCount = 0; retryInterval = 0
+ retryCount = 0
+ retryInterval = 0
bufferSize = 131070
def __init__(self, sock=None, sockMap=None):
asyncore.dispatcher.__init__(self)
@@ -45,7 +46,8 @@ class AbstractSocketTransport(asyncore.dispatcher, AbstractTransport):
sock.setblocking(0)
self.set_socket(sock)
- def __hash__(self): return hash(self.socket)
+ def __hash__(self):
+ return hash(self.socket)
# The following two methods are part of base class so here we overwrite
# them to separate socket management from dispatcher registration tasks.
@@ -62,17 +64,17 @@ class AbstractSocketTransport(asyncore.dispatcher, AbstractTransport):
def registerSocket(self, sockMap=None):
self.add_channel(sockMap)
-
+
def unregisterSocket(self, sockMap=None):
self.del_channel(sockMap)
-
+
def closeTransport(self):
AbstractTransport.closeTransport(self)
self.close()
-
+
# asyncore API
- def handle_close(self): raise error.CarrierError(
- 'Transport unexpectedly closed'
- )
- def handle_error(self): raise
+ def handle_close(self):
+ raise error.CarrierError('Transport unexpectedly closed')
+ def handle_error(self):
+ raise
diff --git a/pysnmp/carrier/asyncore/dgram/base.py b/pysnmp/carrier/asyncore/dgram/base.py
index 37d7b5b2..0e139276 100644
--- a/pysnmp/carrier/asyncore/dgram/base.py
+++ b/pysnmp/carrier/asyncore/dgram/base.py
@@ -23,12 +23,12 @@ class DgramSocketTransport(AbstractSocketTransport):
def __init__(self, sock=None, sockMap=None):
self.__outQueue = []
self._sendto = lambda s,b,a: s.sendto(b, a)
- def __recvfrom(s, sz):
+ def __recvfrom(s, sz):
d, a = s.recvfrom(sz)
return d, self.addressType(a)
self._recvfrom = __recvfrom
AbstractSocketTransport.__init__(self, sock, sockMap)
-
+
def openClientMode(self, iface=None):
if iface is not None:
try:
@@ -129,7 +129,7 @@ class DgramSocketTransport(AbstractSocketTransport):
debug.logger & debug.flagIO and debug.logger('handle_write: ignoring socket error %s' % (sys.exc_info()[1],))
else:
raise error.CarrierError('sendto() failed for %s: %s' % (transportAddress, sys.exc_info()[1]))
-
+
def readable(self): return 1
def handle_read(self):
try:
diff --git a/pysnmp/carrier/asyncore/dgram/udp6.py b/pysnmp/carrier/asyncore/dgram/udp6.py
index 73d0d663..28ba1540 100644
--- a/pysnmp/carrier/asyncore/dgram/udp6.py
+++ b/pysnmp/carrier/asyncore/dgram/udp6.py
@@ -6,7 +6,8 @@ import socket
domainName = snmpUDP6Domain = (1, 3, 6, 1, 2, 1, 100, 1, 2)
-class Udp6TransportAddress(tuple, AbstractTransportAddress): pass
+class Udp6TransportAddress(tuple, AbstractTransportAddress):
+ pass
class Udp6SocketTransport(DgramSocketTransport):
sockFamily = socket.has_ipv6 and socket.AF_INET6 or None
@@ -14,12 +15,10 @@ class Udp6SocketTransport(DgramSocketTransport):
def normalizeAddress(self, transportAddress):
if '%' in transportAddress[0]: # strip zone ID
- ta = self.addressType(
- (transportAddress[0].split('%')[0],
- transportAddress[1],
- 0, # flowinfo
- 0) # scopeid
- )
+ ta = self.addressType((transportAddress[0].split('%')[0],
+ transportAddress[1],
+ 0, # flowinfo
+ 0)) # scopeid
else:
ta = self.addressType(
(transportAddress[0], transportAddress[1], 0, 0)
@@ -30,5 +29,5 @@ class Udp6SocketTransport(DgramSocketTransport):
return ta.setLocalAddress(transportAddress.getLocalAddress())
else:
return ta.setLocalAddress(self.getLocalAddress())
-
+
Udp6Transport = Udp6SocketTransport
diff --git a/pysnmp/carrier/asyncore/dispatch.py b/pysnmp/carrier/asyncore/dispatch.py
index 790152d0..2124bfd8 100644
--- a/pysnmp/carrier/asyncore/dispatch.py
+++ b/pysnmp/carrier/asyncore/dispatch.py
@@ -13,9 +13,12 @@ class AsyncoreDispatcher(AbstractTransportDispatcher):
self.timeout = 0.5
AbstractTransportDispatcher.__init__(self)
- def getSocketMap(self): return self.__sockMap
- def setSocketMap(self, sockMap=socket_map): self.__sockMap = sockMap
-
+ def getSocketMap(self):
+ return self.__sockMap
+
+ def setSocketMap(self, sockMap=socket_map):
+ self.__sockMap = sockMap
+
def registerTransport(self, tDomain, t):
AbstractTransportDispatcher.registerTransport(self, tDomain, t)
t.registerSocket(self.__sockMap)
@@ -29,7 +32,7 @@ class AsyncoreDispatcher(AbstractTransportDispatcher):
if transport.writable():
return 1
return 0
-
+
def runDispatcher(self, timeout=0.0):
while self.jobsArePending() or self.transportsAreWorking():
try:
diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py
index 5d6772a6..08273fb1 100644
--- a/pysnmp/carrier/base.py
+++ b/pysnmp/carrier/base.py
@@ -6,19 +6,30 @@ class TimerCallable:
self.__cbFun = cbFun
self.__callInterval = callInterval
self.__nextCall = 0
-
+
def __call__(self, timeNow):
if self.__nextCall <= timeNow:
self.__cbFun(timeNow)
self.__nextCall = timeNow + self.__callInterval
- def __eq__(self, cbFun): return self.__cbFun == cbFun
- def __ne__(self, cbFun): return self.__cbFun != cbFun
- def __lt__(self, cbFun): return self.__cbFun < cbFun
- def __le__(self, cbFun): return self.__cbFun <= cbFun
- def __gt__(self, cbFun): return self.__cbFun > cbFun
- def __ge__(self, cbFun): return self.__cbFun >= cbFun
-
+ def __eq__(self, cbFun):
+ return self.__cbFun == cbFun
+
+ def __ne__(self, cbFun):
+ return self.__cbFun != cbFun
+
+ def __lt__(self, cbFun):
+ return self.__cbFun < cbFun
+
+ def __le__(self, cbFun):
+ return self.__cbFun <= cbFun
+
+ def __gt__(self, cbFun):
+ return self.__cbFun > cbFun
+
+ def __ge__(self, cbFun):
+ return self.__cbFun >= cbFun
+
class AbstractTransportDispatcher:
def __init__(self):
self.__transports = {}
@@ -31,7 +42,7 @@ class AbstractTransportDispatcher:
self.__timerDelta = self.__timerResolution * 0.05
self.__nextTime = 0
self.__routingCbFun = None
-
+
def _cbFun(self, incomingTransport, transportAddress, incomingMessage):
if incomingTransport in self.__transportDomainMap:
transportDomain = self.__transportDomainMap[incomingTransport]
@@ -115,10 +126,9 @@ class AbstractTransportDispatcher:
raise error.CarrierError(
'Transport %s not registered' % (transportDomain,)
)
-
- def sendMessage(
- self, outgoingMessage, transportDomain, transportAddress
- ):
+
+ def sendMessage(self, outgoingMessage, transportDomain,
+ transportAddress):
if transportDomain in self.__transports:
self.__transports[transportDomain].sendMessage(
outgoingMessage, transportAddress
@@ -130,21 +140,22 @@ class AbstractTransportDispatcher:
def getTimerResolution(self):
return self.__timerResolution
+
def setTimerResolution(self, timerResolution):
if timerResolution < 0.01 or timerResolution > 10:
raise error.CarrierError('Impossible timer resolution')
self.__timerResolution = timerResolution
self.__timerDelta = timerResolution * 0.05
-
+
def getTimerTicks(self): return self.__ticks
-
+
def handleTimerTick(self, timeNow):
if self.__nextTime == 0: # initial initialization
self.__nextTime = timeNow + self.__timerResolution - self.__timerDelta
if self.__nextTime >= timeNow:
return
-
+
self.__ticks += 1
self.__nextTime = timeNow + self.__timerResolution - self.__timerDelta
@@ -170,7 +181,7 @@ class AbstractTransportDispatcher:
def runDispatcher(self, timeout=0.0):
raise error.CarrierError('Method not implemented')
-
+
def closeDispatcher(self):
for tDomain in list(self.__transports):
self.__transports[tDomain].closeTransport()
@@ -184,7 +195,7 @@ class AbstractTransportAddress:
def setLocalAddress(self, s):
self._localAddress = s
return self
-
+
def getLocalAddress(self):
return self._localAddress
@@ -213,12 +224,12 @@ class AbstractTransport:
self.unregisterCbFun()
# Public API
-
+
def openClientMode(self, iface=None):
raise error.CarrierError('Method not implemented')
def openServerMode(self, iface=None):
raise error.CarrierError('Method not implemented')
-
+
def sendMessage(self, outgoingMessage, transportAddress):
raise error.CarrierError('Method not implemented')
diff --git a/pysnmp/carrier/sockmsg.py b/pysnmp/carrier/sockmsg.py
index e83374f5..d84c6aa6 100644
--- a/pysnmp/carrier/sockmsg.py
+++ b/pysnmp/carrier/sockmsg.py
@@ -1,10 +1,10 @@
#
# The following routines act like sendto()/recvfrom() calls but additionally
-# support local address retrieval (what can be useful when listening on
+# support local address retrieval (what can be useful when listening on
# 0.0.0.0 or [::]) and source address spoofing (for transparent proxying).
#
# These routines are based on POSIX sendmsg()/recvmsg() calls which were made
-# available since Python 3.3. Therefore this module is only Python 3.x
+# available since Python 3.3. Therefore this module is only Python 3.x
# compatible.
#
# Parts of the code below is taken from:
@@ -21,34 +21,33 @@ else:
import ctypes
import ipaddress
import socket
- from pysnmp import debug
from pysnmp.carrier import sockfix, error
uint32_t = ctypes.c_uint32
in_addr_t = uint32_t
-
+
class in_addr(ctypes.Structure):
_fields_ = [('s_addr', in_addr_t)]
-
+
class in6_addr_U(ctypes.Union):
_fields_ = [
('__u6_addr8', ctypes.c_uint8 * 16),
('__u6_addr16', ctypes.c_uint16 * 8),
('__u6_addr32', ctypes.c_uint32 * 4),
]
-
+
class in6_addr(ctypes.Structure):
_fields_ = [
('__in6_u', in6_addr_U),
]
-
+
class in_pktinfo(ctypes.Structure):
_fields_ = [
('ipi_ifindex', ctypes.c_int),
('ipi_spec_dst', in_addr),
('ipi_addr', in_addr),
]
-
+
class in6_pktinfo(ctypes.Structure):
_fields_ = [
('ipi6_addr', in6_addr),
@@ -63,14 +62,14 @@ else:
if anc[0] == socket.SOL_IP and anc[1] == socket.IP_PKTINFO:
addr = in_pktinfo.from_buffer_copy(anc[2])
addr = ipaddress.IPv4Address(memoryview(addr.ipi_addr).tobytes())
- _to = (str(addr),s.getsockname()[1])
+ _to = (str(addr), s.getsockname()[1])
elif anc[0] == socket.SOL_IPV6 and anc[1] == socket.IPV6_PKTINFO:
addr = in6_pktinfo.from_buffer_copy(anc[2])
addr = ipaddress.ip_address(memoryview(addr.ipi6_addr).tobytes())
- _to = (str(addr),s.getsockname()[1])
+ _to = (str(addr), s.getsockname()[1])
return data, addressType(_from).setLocalAddress(_to)
return recvfrom
-
+
def getSendTo(addressType):
def sendto(s, _data, _to):
ancdata = []
diff --git a/pysnmp/carrier/twisted/dgram/base.py b/pysnmp/carrier/twisted/dgram/base.py
index 72dbd8e8..883311a6 100644
--- a/pysnmp/carrier/twisted/dgram/base.py
+++ b/pysnmp/carrier/twisted/dgram/base.py
@@ -10,7 +10,7 @@ class DgramTwistedTransport(DatagramProtocol, AbstractTwistedTransport):
"""Base Twisted datagram Transport, to be used with TwistedDispatcher"""
# Twisted Datagram API
-
+
def datagramReceived(self, datagram, transportAddress):
if self._cbFun is None:
raise error.CarrierError('Unable to call cbFun')
diff --git a/pysnmp/carrier/twisted/dgram/udp.py b/pysnmp/carrier/twisted/dgram/udp.py
index 82e2d2b6..7bf9b9c6 100644
--- a/pysnmp/carrier/twisted/dgram/udp.py
+++ b/pysnmp/carrier/twisted/dgram/udp.py
@@ -13,7 +13,7 @@ class UdpTwistedTransport(DgramTwistedTransport):
addressType = UdpTransportAddress
# AbstractTwistedTransport API
-
+
def openClientMode(self, iface=None):
if iface is None:
iface = ('', 0)
diff --git a/pysnmp/carrier/twisted/dgram/unix.py b/pysnmp/carrier/twisted/dgram/unix.py
index dd590b0a..2e9f9db2 100644
--- a/pysnmp/carrier/twisted/dgram/unix.py
+++ b/pysnmp/carrier/twisted/dgram/unix.py
@@ -13,7 +13,7 @@ class UnixTwistedTransport(DgramTwistedTransport):
addressType = UnixTransportAddress
# AbstractTwistedTransport API
-
+
def openClientMode(self, iface=''):
try:
self._lport = reactor.connectUNIXDatagram(iface, self)
@@ -26,7 +26,7 @@ class UnixTwistedTransport(DgramTwistedTransport):
self._lport = reactor.listenUNIXDatagram(iface, self)
except Exception:
raise error.CarrierError(sys.exc_info()[1])
-
+
return self
def closeTransport(self):