diff options
author | elie <elie> | 2011-01-20 17:16:56 +0000 |
---|---|---|
committer | elie <elie> | 2011-01-20 17:16:56 +0000 |
commit | 112326a36b5649e752d042b62a16a5a6d470f51a (patch) | |
tree | 617547a29ac2b60a7b8cb8607d08730c096051b6 | |
parent | b009e5c04a5c462163fe7a1b0968bf752466f6b1 (diff) | |
download | pysnmp-112326a36b5649e752d042b62a16a5a6d470f51a.tar.gz |
python < 2.2 specific code removed
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | pysnmp/carrier/asynsock/base.py | 27 | ||||
-rw-r--r-- | pysnmp/carrier/asynsock/dispatch.py | 29 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/ntforg.py | 6 |
4 files changed, 3 insertions, 61 deletions
@@ -19,7 +19,7 @@ FEATURES * Twisted (http://twistedmatrix.com) integration * IPv6 transport support * Python eggs and py2exe friendly -* 100% Python, works with Python 1.5 though 2.x +* 100% Python, works with Python 2.2 though 2.7 * MT-safe (only if run locally to a thread) Features, specific to SNMPv3 model include: diff --git a/pysnmp/carrier/asynsock/base.py b/pysnmp/carrier/asynsock/base.py index a0525be..e60b340 100644 --- a/pysnmp/carrier/asynsock/base.py +++ b/pysnmp/carrier/asynsock/base.py @@ -1,8 +1,4 @@ """Defines standard API to asyncore-based transport""" -try: - from sys import version_info -except ImportError: - version_info = ( 0, 0 ) # a really early version import socket, sys import asyncore from pysnmp.carrier import error @@ -29,28 +25,7 @@ class AbstractSocketTransport(asyncore.dispatcher): # which this transport is registered, so this is a fake # socket map to avoid registering with deafult asyncore map. sockMap = {} - # Old asyncore doesn't allow socket_map param in constructor - if version_info < (2, 0): - # Taken from dispatcher.__init__() - self.socket = sock - self.add_channel(sockMap) - self.socket.setblocking(0) - self.connected = 1 - else: - asyncore.dispatcher.__init__(self, sock, sockMap) - - # Old asyncore doesn't allow socket_map param - if version_info < (2, 0): - def add_channel (self, sockMap=None): - if sockMap is None: - sockMap = asyncore.socket_map - sockMap[self] = self - - def del_channel (self, sockMap=None): - if sockMap is None: - sockMap = asyncore.socket_map - if self in sockMap: - del sockMap[self] + asyncore.dispatcher.__init__(self, sock, sockMap) def registerSocket(self, sockMap=None): self.add_channel(sockMap) diff --git a/pysnmp/carrier/asynsock/dispatch.py b/pysnmp/carrier/asynsock/dispatch.py index 9354a3a..14f9b22 100644 --- a/pysnmp/carrier/asynsock/dispatch.py +++ b/pysnmp/carrier/asynsock/dispatch.py @@ -1,35 +1,8 @@ -try: - from sys import version_info -except ImportError: - version_info = ( 0, 0 ) # a really early version from time import time from select import select from asyncore import socket_map from pysnmp.carrier.base import AbstractTransportDispatcher - -# Old asyncore doesn't allow socket_map param at poll -if version_info < (2, 0): - def poll(timeout, socket_map): - if not socket_map: - return - sockets = socket_map.keys() - r = filter(lambda x: x.readable(), sockets) - w = filter(lambda x: x.writable(), sockets) - - (r,w,e) = select(r, w, [], timeout) - - for x in r: - try: - x.handle_read_event() - except: - x.handle_error() - for x in w: - try: - x.handle_write_event() - except: - x.handle_error() -else: - from asyncore import poll +from asyncore import poll class AsynsockDispatcher(AbstractTransportDispatcher): """Implements I/O over asynchronous sockets""" diff --git a/pysnmp/entity/rfc3413/ntforg.py b/pysnmp/entity/rfc3413/ntforg.py index 9d5d8e8..3597078 100644 --- a/pysnmp/entity/rfc3413/ntforg.py +++ b/pysnmp/entity/rfc3413/ntforg.py @@ -1,8 +1,4 @@ import time -try: - from sys import version_info -except ImportError: - version_info = ( 0, 0 ) # a really early version from pysnmp.entity.rfc3413 import config from pysnmp.proto.proxy import rfc2576 from pysnmp.proto.api import v2c @@ -191,8 +187,6 @@ class NotificationOriginator: # varBinds.append((objectInstance.name, objectInstance.syntax)) if additionalVarBinds: - if version_info < (1, 6): - additionalVarBinds = list(additionalVarBinds) varBinds.extend(additionalVarBinds) for varName, varVal in varBinds: |