From 1ec923c018fb8b19c19c03fd8c5683e40375aaef Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Fri, 8 Sep 2017 23:45:39 -0400 Subject: [PATCH] sync python versions --- py25/bacpypes/bvll.py | 7 ++++++- py25/bacpypes/vlan.py | 20 +++++++++++++------- py27/bacpypes/bvll.py | 7 ++++++- py27/bacpypes/vlan.py | 20 +++++++++++++------- py34/bacpypes/vlan.py | 20 +++++++++++++------- 5 files changed, 51 insertions(+), 23 deletions(-) diff --git a/py25/bacpypes/bvll.py b/py25/bacpypes/bvll.py index a848c65..2346e7e 100755 --- a/py25/bacpypes/bvll.py +++ b/py25/bacpypes/bvll.py @@ -224,7 +224,7 @@ class WriteBroadcastDistributionTable(BVLPDU): BVLCI.update(bvlpdu, self) for bdte in self.bvlciBDT: bvlpdu.put_data( bdte.addrAddr ) - bvlpdu.put_data( bdte.addrMask ) + bvlpdu.put_long( bdte.addrMask ) def decode(self, bvlpdu): BVLCI.update(self, bvlpdu) @@ -401,6 +401,11 @@ class FDTEntry(DebugContents): self.fdTTL = None self.fdRemain = None + def __eq__(self, other): + """Return true iff entries are identical.""" + return (self.fdAddress == other.fdAddress) and \ + (self.fdTTL == other.fdTTL) and (self.fdRemain == other.fdRemain) + def bvlpdu_contents(self, use_dict=None, as_class=dict): """Return the contents of an object as a dict.""" # make/extend the dictionary of content diff --git a/py25/bacpypes/vlan.py b/py25/bacpypes/vlan.py index e9223f5..731d72e 100755 --- a/py25/bacpypes/vlan.py +++ b/py25/bacpypes/vlan.py @@ -26,9 +26,10 @@ _log = ModuleLogger(globals()) class Network: - def __init__(self, broadcast_address=None, drop_percent=0.0): - if _debug: Network._debug("__init__ broadcast_address=%r drop_percent=%r", broadcast_address, drop_percent) + def __init__(self, name='', broadcast_address=None, drop_percent=0.0): + if _debug: Network._debug("__init__ name=%r broadcast_address=%r drop_percent=%r", name, broadcast_address, drop_percent) + self.name = name self.nodes = [] self.broadcast_address = broadcast_address self.drop_percent = drop_percent @@ -40,6 +41,10 @@ class Network: self.nodes.append(node) node.lan = self + # update the node name + if not node.name: + node.name = '%s:%s' % (self.name, node.address) + def remove_node(self, node): """ Remove a node from this network. """ if _debug: Network._debug("remove_node %r", node) @@ -51,7 +56,7 @@ class Network: """ Process a PDU by sending a copy to each node as dictated by the addressing and if a node is promiscuous. """ - if _debug: Network._debug("process_pdu %r", pdu) + if _debug: Network._debug("[%s]process_pdu %r", self.name, pdu) # randomly drop a packet if self.drop_percent != 0.0: @@ -83,15 +88,16 @@ bacpypes_debugging(Network) class Node(Server): - def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None): + def __init__(self, addr, lan=None, name='', promiscuous=False, spoofing=False, sid=None): if _debug: - Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r", - addr, lan, promiscuous, spoofing, sid + Node._debug("__init__ %r lan=%r name=%r, promiscuous=%r spoofing=%r sid=%r", + addr, lan, name, promiscuous, spoofing, sid ) Server.__init__(self, sid) self.lan = None self.address = addr + self.name = name # bind to a lan if it was provided if lan is not None: @@ -109,7 +115,7 @@ class Node(Server): def indication(self, pdu): """Send a message.""" - if _debug: Node._debug("indication %r", pdu) + if _debug: Node._debug("[%s]indication %r", self.name, pdu) # make sure we're connected if not self.lan: diff --git a/py27/bacpypes/bvll.py b/py27/bacpypes/bvll.py index f4a68b4..30573b7 100755 --- a/py27/bacpypes/bvll.py +++ b/py27/bacpypes/bvll.py @@ -221,7 +221,7 @@ class WriteBroadcastDistributionTable(BVLPDU): BVLCI.update(bvlpdu, self) for bdte in self.bvlciBDT: bvlpdu.put_data( bdte.addrAddr ) - bvlpdu.put_data( bdte.addrMask ) + bvlpdu.put_long( bdte.addrMask ) def decode(self, bvlpdu): BVLCI.update(self, bvlpdu) @@ -398,6 +398,11 @@ class FDTEntry(DebugContents): self.fdTTL = None self.fdRemain = None + def __eq__(self, other): + """Return true iff entries are identical.""" + return (self.fdAddress == other.fdAddress) and \ + (self.fdTTL == other.fdTTL) and (self.fdRemain == other.fdRemain) + def bvlpdu_contents(self, use_dict=None, as_class=dict): """Return the contents of an object as a dict.""" # make/extend the dictionary of content diff --git a/py27/bacpypes/vlan.py b/py27/bacpypes/vlan.py index 723a6af..5fc50b5 100755 --- a/py27/bacpypes/vlan.py +++ b/py27/bacpypes/vlan.py @@ -27,9 +27,10 @@ _log = ModuleLogger(globals()) @bacpypes_debugging class Network: - def __init__(self, broadcast_address=None, drop_percent=0.0): - if _debug: Network._debug("__init__ broadcast_address=%r drop_percent=%r", broadcast_address, drop_percent) + def __init__(self, name='', broadcast_address=None, drop_percent=0.0): + if _debug: Network._debug("__init__ name=%r broadcast_address=%r drop_percent=%r", name, broadcast_address, drop_percent) + self.name = name self.nodes = [] self.broadcast_address = broadcast_address self.drop_percent = drop_percent @@ -41,6 +42,10 @@ class Network: self.nodes.append(node) node.lan = self + # update the node name + if not node.name: + node.name = '%s:%s' % (self.name, node.address) + def remove_node(self, node): """ Remove a node from this network. """ if _debug: Network._debug("remove_node %r", node) @@ -52,7 +57,7 @@ class Network: """ Process a PDU by sending a copy to each node as dictated by the addressing and if a node is promiscuous. """ - if _debug: Network._debug("process_pdu %r", pdu) + if _debug: Network._debug("[%s]process_pdu %r", self.name, pdu) # randomly drop a packet if self.drop_percent != 0.0: @@ -83,15 +88,16 @@ class Network: @bacpypes_debugging class Node(Server): - def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None): + def __init__(self, addr, lan=None, name='', promiscuous=False, spoofing=False, sid=None): if _debug: - Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r", - addr, lan, promiscuous, spoofing, sid + Node._debug("__init__ %r lan=%r name=%r, promiscuous=%r spoofing=%r sid=%r", + addr, lan, name, promiscuous, spoofing, sid ) Server.__init__(self, sid) self.lan = None self.address = addr + self.name = name # bind to a lan if it was provided if lan is not None: @@ -109,7 +115,7 @@ class Node(Server): def indication(self, pdu): """Send a message.""" - if _debug: Node._debug("indication %r", pdu) + if _debug: Node._debug("[%s]indication %r", self.name, pdu) # make sure we're connected if not self.lan: diff --git a/py34/bacpypes/vlan.py b/py34/bacpypes/vlan.py index 723a6af..5fc50b5 100755 --- a/py34/bacpypes/vlan.py +++ b/py34/bacpypes/vlan.py @@ -27,9 +27,10 @@ _log = ModuleLogger(globals()) @bacpypes_debugging class Network: - def __init__(self, broadcast_address=None, drop_percent=0.0): - if _debug: Network._debug("__init__ broadcast_address=%r drop_percent=%r", broadcast_address, drop_percent) + def __init__(self, name='', broadcast_address=None, drop_percent=0.0): + if _debug: Network._debug("__init__ name=%r broadcast_address=%r drop_percent=%r", name, broadcast_address, drop_percent) + self.name = name self.nodes = [] self.broadcast_address = broadcast_address self.drop_percent = drop_percent @@ -41,6 +42,10 @@ class Network: self.nodes.append(node) node.lan = self + # update the node name + if not node.name: + node.name = '%s:%s' % (self.name, node.address) + def remove_node(self, node): """ Remove a node from this network. """ if _debug: Network._debug("remove_node %r", node) @@ -52,7 +57,7 @@ class Network: """ Process a PDU by sending a copy to each node as dictated by the addressing and if a node is promiscuous. """ - if _debug: Network._debug("process_pdu %r", pdu) + if _debug: Network._debug("[%s]process_pdu %r", self.name, pdu) # randomly drop a packet if self.drop_percent != 0.0: @@ -83,15 +88,16 @@ class Network: @bacpypes_debugging class Node(Server): - def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None): + def __init__(self, addr, lan=None, name='', promiscuous=False, spoofing=False, sid=None): if _debug: - Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r", - addr, lan, promiscuous, spoofing, sid + Node._debug("__init__ %r lan=%r name=%r, promiscuous=%r spoofing=%r sid=%r", + addr, lan, name, promiscuous, spoofing, sid ) Server.__init__(self, sid) self.lan = None self.address = addr + self.name = name # bind to a lan if it was provided if lan is not None: @@ -109,7 +115,7 @@ class Node(Server): def indication(self, pdu): """Send a message.""" - if _debug: Node._debug("indication %r", pdu) + if _debug: Node._debug("[%s]indication %r", self.name, pdu) # make sure we're connected if not self.lan: