1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

Merge branch 'DB-CL-patch-2' into develop

This commit is contained in:
Joel Bender 2021-03-29 23:51:30 -04:00
commit f2b22d213a
2 changed files with 19 additions and 19 deletions

View File

@ -7,11 +7,11 @@ that sits behind a NAT and a "global" network of other NAT router peers.
$ python NATRouter.py addr1 port1 net1 addr2 port2 net2
addr1 - local address like 192.168.1.10/24
port1 - local port
net1 - local network number
addr2 - global address like 201.1.1.1:47809
port2 - local mapped port
net2 - global network number
port1 - local port like 47808
net1 - local network number like 1
addr2 - global address like 201.1.1.1
port2 - local mapped port like 47809
net2 - global network number like 2
The sample addresses are like running BR1 from Figure J-8, Clause J.7.5.
"""
@ -67,7 +67,7 @@ class NATRouter:
# global address
global_addr = Address(addr2)
nat_addr = Address("{}:{}".format(addr1, port2))
nat_addr = Address("{}:{}".format(addr2, port2))
# create a NAT stack
self.s2_bip = BIPNAT(global_addr)

View File

@ -228,7 +228,7 @@ class IOCB(DebugContents):
def __repr__(self):
xid = id(self)
if (xid < 0): xid += (1L << 32)
if (xid < 0): xid += (1 << 32)
sname = self.__module__ + '.' + self.__class__.__name__
desc = "(%d)" % (self.ioID,)
@ -317,7 +317,7 @@ class IOChainMixIn(DebugContents):
# make sure we're being notified of an abort request from
# the iocb we are chained from
if iocb is not self.ioChain:
raise RuntimeError, "broken chain"
raise RuntimeError("broken chain")
# call my own abort(), which may forward it to a controller or
# be overridden by IOGroup
@ -355,7 +355,7 @@ class IOChainMixIn(DebugContents):
iocb.ioError = self.ioError
else:
raise RuntimeError, "invalid state: %d" % (self.ioState,)
raise RuntimeError("invalid state: %d" % (self.ioState,))
#
# IOChain
@ -463,7 +463,7 @@ class IOQueue:
# requests should be pending before being queued
if iocb.ioState != PENDING:
raise RuntimeError, "invalid state transition"
raise RuntimeError("invalid state transition")
# save that it might have been empty
wasempty = not self.notempty.isSet()
@ -566,7 +566,7 @@ class IOController:
# register the name
if name is not None:
if name in _local_controllers:
raise RuntimeError, "already a local controller called '%s': %r" % (name, _local_controllers[name])
raise RuntimeError("already a local controller called '%s': %r" % (name, _local_controllers[name]))
_local_controllers[name] = self
def abort(self, err):
@ -600,7 +600,7 @@ class IOController:
def process_io(self, iocb):
"""Figure out how to respond to this request. This must be
provided by the derived class."""
raise NotImplementedError, "IOController must implement process_io()"
raise NotImplementedError("IOController must implement process_io()")
def active_io(self, iocb):
"""Called by a handler to notify the controller that a request is
@ -609,7 +609,7 @@ class IOController:
# requests should be idle or pending before coming active
if (iocb.ioState != IDLE) and (iocb.ioState != PENDING):
raise RuntimeError, "invalid state transition (currently %d)" % (iocb.ioState,)
raise RuntimeError("invalid state transition (currently %d)" % (iocb.ioState,))
# change the state
iocb.ioState = ACTIVE
@ -737,7 +737,7 @@ class IOQController(IOController):
def process_io(self, iocb):
"""Figure out how to respond to this request. This must be
provided by the derived class."""
raise NotImplementedError, "IOController must implement process_io()"
raise NotImplementedError("IOController must implement process_io()")
def active_io(self, iocb):
"""Called by a handler to notify the controller that a request is
@ -759,7 +759,7 @@ class IOQController(IOController):
# check to see if it is completing the active one
if iocb is not self.active_iocb:
raise RuntimeError, "not the current iocb"
raise RuntimeError("not the current iocb")
# normal completion
IOController.complete_io(self, iocb, msg)
@ -845,7 +845,7 @@ class IOQController(IOController):
# make sure we are waiting
if (self.state != CTRL_WAITING):
raise RuntimeError, "not waiting"
raise RuntimeError("not waiting")
# change our state
self.state = CTRL_IDLE
@ -1017,7 +1017,7 @@ class IOServer(IOController, Client):
elif iocb.ioState == ABORTED:
response = (2, clientID, iocb.ioError)
else:
raise RuntimeError, "IOCB invalid state"
raise RuntimeError("IOCB invalid state")
if _debug: _commlog.debug("<<< %s: S %s %r" % (_strftime(), clientAddr, response))
@ -1224,7 +1224,7 @@ class IOProxyServer(IOController, Client):
self.request(PDU(request, destination=(iocb.ioServerRef, PORT)))
else:
raise RuntimeError, "no reference to aborting iocb: %r" % (iocb.ioID,)
raise RuntimeError("no reference to aborting iocb: %r" % (iocb.ioID,))
# change the state
iocb.ioState = ABORTED
@ -1264,7 +1264,7 @@ class IOProxyServer(IOController, Client):
if _debug: IOProxyServer._debug("abort_iocb %r %r %r", addr, iocbid, err)
if not self.localIOCB.has_key(iocbid):
raise RuntimeError, "no reference to aborting iocb: %r" % (iocbid,)
raise RuntimeError("no reference to aborting iocb: %r" % (iocbid,))
# get the iocb
iocb = self.localIOCB[iocbid]