summaryrefslogtreecommitdiff
path: root/pysnmp/carrier/asyncio/dgram
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-02-10 16:38:35 +0100
committerGitHub <noreply@github.com>2019-02-10 16:38:35 +0100
commit588b9b902d191d8010cb6b247fcb07887d59542c (patch)
tree419b01d2598e91331db784ac3a6675324aba8c24 /pysnmp/carrier/asyncio/dgram
parent9664858b145140a4fbb2a22b633c1ab41c2555bd (diff)
downloadpysnmp-git-588b9b902d191d8010cb6b247fcb07887d59542c.tar.gz
Uppercase global constants (#238)
This is a massive patch essentially upper-casing global/class attributes that mean to be constants. Some previously exposed constants have been preserved for compatibility reasons (notably, in `hlapi`), though the rest might break user code relying on pysnmp 4.
Diffstat (limited to 'pysnmp/carrier/asyncio/dgram')
-rw-r--r--pysnmp/carrier/asyncio/dgram/base.py23
-rw-r--r--pysnmp/carrier/asyncio/dgram/udp.py4
-rw-r--r--pysnmp/carrier/asyncio/dgram/udp6.py4
3 files changed, 16 insertions, 15 deletions
diff --git a/pysnmp/carrier/asyncio/dgram/base.py b/pysnmp/carrier/asyncio/dgram/base.py
index a845fa1e..7cc0b589 100644
--- a/pysnmp/carrier/asyncio/dgram/base.py
+++ b/pysnmp/carrier/asyncio/dgram/base.py
@@ -47,8 +47,9 @@ IS_PYTHON_344_PLUS = platform.python_version_tuple() >= ('3', '4', '4')
class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
"""Base Asyncio datagram Transport, to be used with AsyncioDispatcher"""
- sockFamily = None
- addressType = lambda x: x
+ SOCK_FAMILY = None
+ ADDRESS_TYPE = lambda x: x
+
transport = None
def __init__(self, sock=None, sockMap=None, loop=None):
@@ -66,25 +67,25 @@ class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
def connection_made(self, transport):
self.transport = transport
- debug.logger & debug.flagIO and debug.logger('connection_made: invoked')
+ debug.logger & debug.FLAG_IO and debug.logger('connection_made: invoked')
while self._writeQ:
outgoingMessage, transportAddress = self._writeQ.pop(0)
- debug.logger & debug.flagIO and debug.logger('connection_made: transportAddress %r outgoingMessage %s' %
- (transportAddress, debug.hexdump(outgoingMessage)))
+ debug.logger & debug.FLAG_IO and debug.logger('connection_made: transportAddress %r outgoingMessage %s' %
+ (transportAddress, debug.hexdump(outgoingMessage)))
try:
self.transport.sendto(outgoingMessage, self.normalizeAddress(transportAddress))
except Exception:
raise error.CarrierError(';'.join(traceback.format_exception(*sys.exc_info())))
def connection_lost(self, exc):
- debug.logger & debug.flagIO and debug.logger('connection_lost: invoked')
+ debug.logger & debug.FLAG_IO and debug.logger('connection_lost: invoked')
# AbstractAsyncioTransport API
def openClientMode(self, iface=None):
try:
c = self.loop.create_datagram_endpoint(
- lambda: self, local_addr=iface, family=self.sockFamily
+ lambda: self, local_addr=iface, family=self.SOCK_FAMILY
)
# Avoid deprecation warning for asyncio.async()
if IS_PYTHON_344_PLUS:
@@ -99,7 +100,7 @@ class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
def openServerMode(self, iface):
try:
c = self.loop.create_datagram_endpoint(
- lambda: self, local_addr=iface, family=self.sockFamily
+ lambda: self, local_addr=iface, family=self.SOCK_FAMILY
)
# Avoid deprecation warning for asyncio.async()
if IS_PYTHON_344_PLUS:
@@ -118,7 +119,7 @@ class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
AbstractAsyncioTransport.closeTransport(self)
def sendMessage(self, outgoingMessage, transportAddress):
- debug.logger & debug.flagIO and debug.logger('sendMessage: %s transportAddress %r outgoingMessage %s' % (
+ debug.logger & debug.FLAG_IO and debug.logger('sendMessage: %s transportAddress %r outgoingMessage %s' % (
(self.transport is None and "queuing" or "sending"),
transportAddress, debug.hexdump(outgoingMessage)
))
@@ -131,6 +132,6 @@ class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
raise error.CarrierError(';'.join(traceback.format_exception(*sys.exc_info())))
def normalizeAddress(self, transportAddress):
- if not isinstance(transportAddress, self.addressType):
- transportAddress = self.addressType(transportAddress)
+ if not isinstance(transportAddress, self.ADDRESS_TYPE):
+ transportAddress = self.ADDRESS_TYPE(transportAddress)
return transportAddress
diff --git a/pysnmp/carrier/asyncio/dgram/udp.py b/pysnmp/carrier/asyncio/dgram/udp.py
index 41ada723..b13d4202 100644
--- a/pysnmp/carrier/asyncio/dgram/udp.py
+++ b/pysnmp/carrier/asyncio/dgram/udp.py
@@ -42,8 +42,8 @@ class UdpTransportAddress(tuple, AbstractTransportAddress):
class UdpAsyncioTransport(DgramAsyncioProtocol):
- sockFamily = socket.AF_INET
- addressType = UdpTransportAddress
+ SOCK_FAMILY = socket.AF_INET
+ ADDRESS_TYPE = UdpTransportAddress
UdpTransport = UdpAsyncioTransport
diff --git a/pysnmp/carrier/asyncio/dgram/udp6.py b/pysnmp/carrier/asyncio/dgram/udp6.py
index bc03b447..f3708852 100644
--- a/pysnmp/carrier/asyncio/dgram/udp6.py
+++ b/pysnmp/carrier/asyncio/dgram/udp6.py
@@ -17,8 +17,8 @@ class Udp6TransportAddress(tuple, AbstractTransportAddress):
class Udp6AsyncioTransport(DgramAsyncioProtocol):
- sockFamily = socket.has_ipv6 and socket.AF_INET6 or None
- addressType = Udp6TransportAddress
+ SOCK_FAMILY = socket.has_ipv6 and socket.AF_INET6 or None
+ ADDRESS_TYPE = Udp6TransportAddress
def normalizeAddress(self, transportAddress):
if '%' in transportAddress[0]: # strip zone ID