Force types to be integers in Python

Replace:
min(data[node]['downloadBandwidthMbps'],parentMaxDL)

With:
min(int(data[node]['downloadBandwidthMbps']),int(parentMaxDL))

Python thought my current configuration contained a string for one
of the numbers. It was a string representing an int. Force strong
typing (a non-numeric will fail, but it would fail anyway).
This commit is contained in:
Herbert Wolverson 2023-03-03 14:25:36 +00:00
parent 433e7ac877
commit 24722aa608

View File

@ -545,8 +545,8 @@ def refreshShapers():
if isinstance(node, str):
if (isinstance(data[node], dict)) and (node != 'children'):
# Cap based on this node's max bandwidth, or parent node's max bandwidth, whichever is lower
data[node]['downloadBandwidthMbps'] = min(data[node]['downloadBandwidthMbps'],parentMaxDL)
data[node]['uploadBandwidthMbps'] = min(data[node]['uploadBandwidthMbps'],parentMaxUL)
data[node]['downloadBandwidthMbps'] = min(int(data[node]['downloadBandwidthMbps']),int(parentMaxDL))
data[node]['uploadBandwidthMbps'] = min(int(data[node]['uploadBandwidthMbps']),int(parentMaxUL))
# Recursive call this function for children nodes attached to this node
if 'children' in data[node]:
# We need to keep tabs on the minor counter, because we can't have repeating class IDs. Here, we bring back the minor counter from the recursive function