Skip to content

Commit

Permalink
version 0.16.4 released
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBender committed Oct 8, 2017
1 parent a765bf4 commit 6fe4dc1
Show file tree
Hide file tree
Showing 21 changed files with 741 additions and 41 deletions.
2 changes: 1 addition & 1 deletion py25/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.16.3'
__version__ = '0.16.4'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
11 changes: 11 additions & 0 deletions py25/bacpypes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ def get_device_info(self, key):
current_info = DeviceInfo()
current_info.address = key
current_info._cache_keys = (None, key)
current_info._ref_count = 1

self.cache[key] = current_info
else:
if _debug: DeviceInfoCache._debug(" - reference bump")
current_info._ref_count += 1

if _debug: DeviceInfoCache._debug(" - current_info: %r", current_info)

Expand Down Expand Up @@ -177,11 +181,18 @@ def release_device_info(self, info):
has finished with the device information."""
if _debug: DeviceInfoCache._debug("release_device_info %r", info)

# this information record might be used by more than one SSM
if info._ref_count > 1:
if _debug: DeviceInfoCache._debug(" - multiple references")
info._ref_count -= 1
return

cache_id, cache_address = info._cache_keys
if cache_id is not None:
del self.cache[cache_id]
if cache_address is not None:
del self.cache[cache_address]
if _debug: DeviceInfoCache._debug(" - released")

bacpypes_debugging(DeviceInfoCache)

Expand Down
5 changes: 5 additions & 0 deletions py25/bacpypes/constructeddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ def index(self, value):
# not found
raise ValueError("%r not in array" % (value,))

def remove(self, item):
# find the index of the item and delete it
indx = self.index(item)
self.__delitem__(indx)

def encode(self, taglist):
if _debug: ArrayOf._debug("(%r)encode %r", self.__class__.__name__, taglist)

Expand Down
4 changes: 2 additions & 2 deletions py25/bacpypes/pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def decode_address(self, addr):
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1

elif isinstance(addr, str):
elif isinstance(addr, basestring):
if _debug: Address._debug(" - str")

m = ip_address_mask_port_re.match(addr)
Expand Down Expand Up @@ -263,7 +263,7 @@ def decode_address(self, addr):
addr, port = addr
self.addrPort = int(port)

if isinstance(addr, str):
if isinstance(addr, basestring):
if not addr:
# when ('', n) is passed it is the local host address, but that
# could be more than one on a multihomed machine, the empty string
Expand Down
14 changes: 7 additions & 7 deletions py25/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def __init__(self, arg=None):
# convert it to a string if you can
self.value = self._xlate_table.get(arg, arg)

elif isinstance(arg, str):
elif isinstance(arg, basestring):
if arg not in self._xlate_table:
raise ValueError("undefined enumeration '%s'" % (arg,))
self.value = arg
Expand All @@ -1088,7 +1088,7 @@ def __getitem__(self, item):
def get_long(self):
if isinstance(self.value, (int, long)):
return self.value
elif isinstance(self.value, str):
elif isinstance(self.value, basestring):
return long(self._xlate_table[self.value])
else:
raise TypeError("%s is an invalid enumeration value datatype" % (type(self.value),))
Expand Down Expand Up @@ -1132,7 +1132,7 @@ def encode(self, tag):
value = long(self.value)
elif isinstance(self.value, long):
value = self.value
elif isinstance(self.value, str):
elif isinstance(self.value, basestring):
value = self._xlate_table[self.value]
else:
raise TypeError("%s is an invalid enumeration value datatype" % (type(self.value),))
Expand Down Expand Up @@ -1170,7 +1170,7 @@ def is_valid(cls, arg):
value is wrong for the enumeration, the encoding will fail.
"""
return (isinstance(arg, (int, long)) and (arg >= 0)) or \
isinstance(arg, str)
isinstance(arg, basestring)

def __str__(self):
return "%s(%s)" % (self.__class__.__name__, self.value)
Expand Down Expand Up @@ -1607,7 +1607,7 @@ def set_tuple(self, objType, objInstance):
objType = self.objectTypeClass._xlate_table.get(objType, objType)
elif isinstance(objType, long):
objType = self.objectTypeClass._xlate_table.get(objType, int(objType))
elif isinstance(objType, str):
elif isinstance(objType, basestring):
# make sure the type is known
if objType not in self.objectTypeClass._xlate_table:
raise ValueError("unrecognized object type '%s'" % (objType,))
Expand All @@ -1629,7 +1629,7 @@ def get_tuple(self):
pass
elif isinstance(objType, long):
objType = int(objType)
elif isinstance(objType, str):
elif isinstance(objType, basestring):
# turn it back into an integer
objType = self.objectTypeClass()[objType]
else:
Expand Down Expand Up @@ -1680,7 +1680,7 @@ def __str__(self):
# rip it apart
objType, objInstance = self.value

if isinstance(objType, str):
if isinstance(objType, basestring):
typestr = objType
elif objType < 0:
typestr = "Bad %d" % (objType,)
Expand Down
2 changes: 1 addition & 1 deletion py27/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.16.3'
__version__ = '0.16.4'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
11 changes: 11 additions & 0 deletions py27/bacpypes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ def get_device_info(self, key):
current_info = DeviceInfo()
current_info.address = key
current_info._cache_keys = (None, key)
current_info._ref_count = 1

self.cache[key] = current_info
else:
if _debug: DeviceInfoCache._debug(" - reference bump")
current_info._ref_count += 1

if _debug: DeviceInfoCache._debug(" - current_info: %r", current_info)

Expand Down Expand Up @@ -177,11 +181,18 @@ def release_device_info(self, info):
has finished with the device information."""
if _debug: DeviceInfoCache._debug("release_device_info %r", info)

# this information record might be used by more than one SSM
if info._ref_count > 1:
if _debug: DeviceInfoCache._debug(" - multiple references")
info._ref_count -= 1
return

cache_id, cache_address = info._cache_keys
if cache_id is not None:
del self.cache[cache_id]
if cache_address is not None:
del self.cache[cache_address]
if _debug: DeviceInfoCache._debug(" - released")

#
# Application
Expand Down
5 changes: 5 additions & 0 deletions py27/bacpypes/constructeddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ def index(self, value):
# not found
raise ValueError("%r not in array" % (value,))

def remove(self, item):
# find the index of the item and delete it
indx = self.index(item)
self.__delitem__(indx)

def encode(self, taglist):
if _debug: ArrayOf._debug("(%r)encode %r", self.__class__.__name__, taglist)

Expand Down
4 changes: 2 additions & 2 deletions py27/bacpypes/pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def decode_address(self, addr):
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1

elif isinstance(addr, str):
elif isinstance(addr, basestring):
if _debug: Address._debug(" - str")

m = ip_address_mask_port_re.match(addr)
Expand Down Expand Up @@ -259,7 +259,7 @@ def decode_address(self, addr):
addr, port = addr
self.addrPort = int(port)

if isinstance(addr, str):
if isinstance(addr, basestring):
if not addr:
# when ('', n) is passed it is the local host address, but that
# could be more than one on a multihomed machine, the empty string
Expand Down
12 changes: 6 additions & 6 deletions py27/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ def __init__(self, arg=None):
# convert it to a string if you can
self.value = self._xlate_table.get(arg, arg)

elif isinstance(arg, str):
elif isinstance(arg, basestring):
if arg not in self._xlate_table:
raise ValueError("undefined enumeration '%s'" % (arg,))
self.value = arg
Expand All @@ -1093,7 +1093,7 @@ def __getitem__(self, item):
def get_long(self):
if isinstance(self.value, (int, long)):
return self.value
elif isinstance(self.value, str):
elif isinstance(self.value, basestring):
return long(self._xlate_table[self.value])
else:
raise TypeError("%s is an invalid enumeration value datatype" % (type(self.value),))
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def encode(self, tag):
value = long(self.value)
elif isinstance(self.value, long):
value = self.value
elif isinstance(self.value, str):
elif isinstance(self.value, basestring):
value = self._xlate_table[self.value]
else:
raise TypeError("%s is an invalid enumeration value datatype" % (type(self.value),))
Expand Down Expand Up @@ -1613,7 +1613,7 @@ def set_tuple(self, objType, objInstance):
objType = self.objectTypeClass._xlate_table.get(objType, objType)
elif isinstance(objType, long):
objType = self.objectTypeClass._xlate_table.get(objType, int(objType))
elif isinstance(objType, str):
elif isinstance(objType, basestring):
# make sure the type is known
if objType not in self.objectTypeClass._xlate_table:
raise ValueError("unrecognized object type '%s'" % (objType,))
Expand All @@ -1635,7 +1635,7 @@ def get_tuple(self):
pass
elif isinstance(objType, long):
objType = int(objType)
elif isinstance(objType, str):
elif isinstance(objType, basestring):
# turn it back into an integer
objType = self.objectTypeClass()[objType]
else:
Expand Down Expand Up @@ -1686,7 +1686,7 @@ def __str__(self):
# rip it apart
objType, objInstance = self.value

if isinstance(objType, str):
if isinstance(objType, basestring):
typestr = objType
elif objType < 0:
typestr = "Bad %d" % (objType,)
Expand Down
2 changes: 1 addition & 1 deletion py34/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.16.3'
__version__ = '0.16.4'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
11 changes: 11 additions & 0 deletions py34/bacpypes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ def get_device_info(self, key):
current_info = DeviceInfo()
current_info.address = key
current_info._cache_keys = (None, key)
current_info._ref_count = 1

self.cache[key] = current_info
else:
if _debug: DeviceInfoCache._debug(" - reference bump")
current_info._ref_count += 1

if _debug: DeviceInfoCache._debug(" - current_info: %r", current_info)

Expand Down Expand Up @@ -177,11 +181,18 @@ def release_device_info(self, info):
has finished with the device information."""
if _debug: DeviceInfoCache._debug("release_device_info %r", info)

# this information record might be used by more than one SSM
if info._ref_count > 1:
if _debug: DeviceInfoCache._debug(" - multiple references")
info._ref_count -= 1
return

cache_id, cache_address = info._cache_keys
if cache_id is not None:
del self.cache[cache_id]
if cache_address is not None:
del self.cache[cache_address]
if _debug: DeviceInfoCache._debug(" - released")

#
# Application
Expand Down
5 changes: 5 additions & 0 deletions py34/bacpypes/constructeddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ def index(self, value):
# not found
raise ValueError("%r not in array" % (value,))

def remove(self, item):
# find the index of the item and delete it
indx = self.index(item)
self.__delitem__(indx)

def encode(self, taglist):
if _debug: ArrayOf._debug("(%r)encode %r", self.__class__.__name__, taglist)

Expand Down
Loading

0 comments on commit 6fe4dc1

Please sign in to comment.