diff options
author | Ilya Etingof <etingof@gmail.com> | 2018-02-24 22:23:50 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2018-02-25 00:08:01 +0100 |
commit | 0a29dd1f35da0523708e7f0bed5cd3ceb28ee538 (patch) | |
tree | 2b0739b67406d4121eb2ecd95cea0cba4819614e /pysnmp/carrier | |
parent | f38ae966c0ebb53a24af4f8d1484b9b01233e8ab (diff) | |
download | pysnmp-git-0a29dd1f35da0523708e7f0bed5cd3ceb28ee538.tar.gz |
many backward-compatibility aids dropped
Diffstat (limited to 'pysnmp/carrier')
-rw-r--r-- | pysnmp/carrier/asyncore/dgram/unix.py | 61 | ||||
-rw-r--r-- | pysnmp/carrier/asynsock/dgram/unix.py | 7 | ||||
-rw-r--r-- | pysnmp/carrier/twisted/dgram/unix.py | 46 |
3 files changed, 0 insertions, 114 deletions
diff --git a/pysnmp/carrier/asyncore/dgram/unix.py b/pysnmp/carrier/asyncore/dgram/unix.py deleted file mode 100644 index 6ab1e5fd..00000000 --- a/pysnmp/carrier/asyncore/dgram/unix.py +++ /dev/null @@ -1,61 +0,0 @@ -# -# This file is part of pysnmp software. -# -# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pysnmp/license.html -# -import os -import random - -try: - from socket import AF_UNIX -except ImportError: - AF_UNIX = None -from pysnmp.carrier.base import AbstractTransportAddress -from pysnmp.carrier.asyncore.dgram.base import DgramSocketTransport - -domainName = snmpLocalDomain = (1, 3, 6, 1, 2, 1, 100, 1, 13) - -random.seed() - - -class UnixTransportAddress(str, AbstractTransportAddress): - pass - - -class UnixSocketTransport(DgramSocketTransport): - sockFamily = AF_UNIX - addressType = UnixTransportAddress - _iface = '' - - def openClientMode(self, iface=None): - if iface is None: - # UNIX domain sockets must be explicitly bound - iface = '' - while len(iface) < 8: - iface += chr(random.randrange(65, 91)) - iface += chr(random.randrange(97, 123)) - iface = os.path.sep + 'tmp' + os.path.sep + 'pysnmp' + iface - if os.path.exists(iface): - os.remove(iface) - DgramSocketTransport.openClientMode(self, iface) - self._iface = iface - return self - - def openServerMode(self, iface): - DgramSocketTransport.openServerMode(self, iface) - self._iface = iface - return self - - def closeTransport(self): - DgramSocketTransport.closeTransport(self) - try: - os.remove(self._iface) - except OSError: - pass - - -UnixTransport = UnixSocketTransport - -# Compatibility stub -UnixDgramSocketTransport = UnixSocketTransport diff --git a/pysnmp/carrier/asynsock/dgram/unix.py b/pysnmp/carrier/asynsock/dgram/unix.py deleted file mode 100644 index 6e75628a..00000000 --- a/pysnmp/carrier/asynsock/dgram/unix.py +++ /dev/null @@ -1,7 +0,0 @@ -# -# This file is part of pysnmp software. -# -# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pysnmp/license.html -# -from pysnmp.carrier.asyncore.dgram.unix import * diff --git a/pysnmp/carrier/twisted/dgram/unix.py b/pysnmp/carrier/twisted/dgram/unix.py deleted file mode 100644 index 5695baad..00000000 --- a/pysnmp/carrier/twisted/dgram/unix.py +++ /dev/null @@ -1,46 +0,0 @@ -# -# This file is part of pysnmp software. -# -# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com> -# License: http://snmplabs.com/pysnmp/license.html -# -import sys -from twisted.internet import reactor -from pysnmp.carrier.base import AbstractTransportAddress -from pysnmp.carrier.twisted.dgram.base import DgramTwistedTransport -from pysnmp.carrier import error - -domainName = snmpLocalDomain = (1, 3, 6, 1, 2, 1, 100, 1, 13) - -class UnixTransportAddress(str, AbstractTransportAddress): - pass - -class UnixTwistedTransport(DgramTwistedTransport): - addressType = UnixTransportAddress - _lport = None - - # AbstractTwistedTransport API - - def openClientMode(self, iface=''): - try: - self._lport = reactor.connectUNIXDatagram(iface, self) - except Exception: - raise error.CarrierError(sys.exc_info()[1]) - return self - - def openServerMode(self, iface): - try: - self._lport = reactor.listenUNIXDatagram(iface, self) - except Exception: - raise error.CarrierError(sys.exc_info()[1]) - - return self - - def closeTransport(self): - if self._lport is not None: - d = self._lport.stopListening() - if d: - d.addCallback(lambda x: None) - DgramTwistedTransport.closeTransport(self) - -UnixTransport = UnixTwistedTransport |