Skip to content

Commit

Permalink
Replace long() with int().
Browse files Browse the repository at this point in the history
The long() and int() were made equivalent in Python 2.4 and long() and
the 'long' type was removed in Python 3.
  • Loading branch information
jpeacock-zenoss committed Jun 4, 2024
1 parent 8c6b797 commit 9668556
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions Products/DataCollector/CommandParsers/Unix_df_k.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def parse(self, device, results, log):
try:
om = self.newObjectMap("ZenModel.FileSystem")
om["storageDevice"] = aline[0]
om["totalBytes"] = long(aline[1]) * 1024
om["usedBytes"] = long(aline[2]) * 1024
om["availBytes"] = long(aline[3]) * 1024
om["totalBytes"] = int(aline[1]) * 1024
om["usedBytes"] = int(aline[2]) * 1024
om["availBytes"] = int(aline[3]) * 1024
cap = aline[4][-1] == "%" and aline[4][:-1] or aline[4]
om["capacity"] = cap
om["mount"] = aline[5]
Expand Down
2 changes: 1 addition & 1 deletion Products/DataCollector/plugins/zenoss/cmd/df.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def process(self, device, results, log):
om.totalBlocks = 0
else:
try:
om.totalBlocks = long(tblocks)
om.totalBlocks = int(tblocks)
except ValueError:
# Ignore this filesystem if what we thought was total
# blocks isn't a number.
Expand Down
4 changes: 2 additions & 2 deletions Products/DataCollector/plugins/zenoss/snmp/HRFileSystemMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ def process(self, device, results, log):
totalBlocks = unsigned(totalBlocks)
fs["totalBlocks"] = totalBlocks

size = long(fs["blockSize"] * totalBlocks)
size = int(fs["blockSize"] * totalBlocks)
if size <= 0:
log.info("Skipping %s. 0 total blocks.", fs["mount"])
continue

fs["type"] = self.typemap.get(fs["type"], "other")
size = long(fs["blockSize"] * totalBlocks)
size = int(fs["blockSize"] * totalBlocks)

# Handle file systems that need to be mapped into other parts of
# the model such as total memory or total swap.
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenEvents/tests/test_zentrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_decode_value_ipv6(self):
)

def test_decode_long_values(self):
value = long(555)
value = int(555)
self.assertEqual(
decode_snmp_value(value),
int(555)
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenHub/services/DiscoverService.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def fullIpList(self):
net = IPNetwork(ipunwrap(self.id))
if self.netmask == net.max_prefixlen:
return [ipunwrap(self.id)]
ipnumb = long(int(net))
ipnumb = int(net)
maxip = math.pow(2, net.max_prefixlen - self.netmask)
start = int(ipnumb + 1)
end = int(ipnumb + maxip - 1)
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenModel/Commandable.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def manage_doUserCommand(self, commandId=None, REQUEST=None):
self.write(out, '')
self.write(out, '')
self.write(out, 'DONE in %s seconds on %s targets' %
(long(time.time() - startTime), numTargets))
(int(time.time() - startTime), numTargets))
REQUEST.RESPONSE.write(str(footer))


Expand Down
2 changes: 1 addition & 1 deletion Products/ZenModel/Fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def rpm(self, default=None):
"""
rpm = self.cacheRRDValue('rpm', default)
if rpm is not None and not isnan(rpm):
return long(rpm)
return int(rpm)
return None


Expand Down
6 changes: 3 additions & 3 deletions Products/ZenModel/FileSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ def usedBlocks(self, default = None):

blocks = self.cacheRRDValue('usedBlocks', default)
if blocks is not None and not isnan(blocks):
return long(blocks)
return int(blocks)
elif self.blockSize:
# no usedBlocks datapoint, so this is probably a Windows device
# using perfmon for data collection and therefore we'll look for
# the freeMegabytes datapoint
freeMB = self.cacheRRDValue('FreeMegabytes', default)
if freeMB is not None and not isnan(freeMB):
usedBytes = self.totalBytes() - long(freeMB) * 1024 * 1024
usedBytes = self.totalBytes() - int(freeMB) * 1024 * 1024
return usedBytes / self.blockSize
return None

Expand All @@ -225,7 +225,7 @@ def availBlocks(self, default = None):
"""
blocks = self.cacheRRDValue('availBlocks', default)
if blocks is not None and not isnan(blocks):
return long(blocks)
return int(blocks)
usedBlocks = self.usedBlocks()
if usedBlocks is None:
return None
Expand Down
4 changes: 2 additions & 2 deletions Products/ZenModel/GraphPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def manage_editProperties(self, REQUEST):

def IsHex(s):
try:
_ = long(color, 16)
_ = int(color, 16)
except ValueError:
return False
return True
Expand Down Expand Up @@ -178,7 +178,7 @@ def getColor(self, index):
if self.color:
color = self.color
try:
_ = long(color.replace("#", ""), 16)
_ = int(color.replace("#", ""), 16)
except ValueError:
color = None
if not color:
Expand Down
10 changes: 5 additions & 5 deletions Products/ZenModel/IpNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def get_subnets_paths(self, net_obj):
subnets = []
if net_obj:
net = IPNetwork(ipunwrap(net_obj.id)) # addr.IPNetwork
first_decimal_ip = long(int(net.network))
last_decimal_ip = long(first_decimal_ip + math.pow(2, net.max_prefixlen - net_obj.netmask) - 1)
first_decimal_ip = int(net.network)
last_decimal_ip = int(first_decimal_ip + math.pow(2, net.max_prefixlen - net_obj.netmask) - 1)
for net_uids in self.cache.values(min=first_decimal_ip, max=last_decimal_ip, excludemin=True, excludemax=True):
subnets.extend(net_uids)
return subnets
Expand Down Expand Up @@ -522,7 +522,7 @@ def get_net_from_catalog(self, ip):
if result.total > 0:
# networks found. if more than network is found, return the one
# whose lastDecimalIp - firstDecimalIp is the smallest
net_brains_tuples = [ ( net_brain, long(net_brain.lastDecimalIp) - long(net_brain.firstDecimalIp) ) for net_brain in result.results ]
net_brains_tuples = [ ( net_brain, int(net_brain.lastDecimalIp) - int(net_brain.firstDecimalIp) ) for net_brain in result.results ]
net_brain_tuple = min(net_brains_tuples, key=lambda x: x[1])
net = net_brain_tuple[0].getObject()
return net
Expand Down Expand Up @@ -575,7 +575,7 @@ def hasIp(self, ip):
Could this network contain this IP?
"""
net = IPNetwork(ipunwrap(self.id))
start = long(int(net.network))
start = int(net.network)
end = start + math.pow(2, net.max_prefixlen - self.netmask)
return start <= numbip(ip) < end

Expand All @@ -584,7 +584,7 @@ def fullIpList(self):
"""
net = IPNetwork(ipunwrap(self.id))
if (self.netmask == net.max_prefixlen): return [self.id]
ipnumb = long(int(net))
ipnumb = int(net)
maxip = math.pow(2, net.max_prefixlen - self.netmask)
start = int(ipnumb+1)
end = int(ipnumb+maxip-1)
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenModel/PowerSupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def millivolts(self, default=None):
"""
millivolts = self.cacheRRDValue('millivolts', default)
if millivolts is not None:
return long(millivolts)
return int(millivolts)
return None


Expand Down
2 changes: 1 addition & 1 deletion Products/ZenModel/RRDDataPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def zmanage_editProperties(self, REQUEST=None, redirect=False):
v = REQUEST.form.get(optional, None)
if v:
try:
REQUEST.form[optional] = long(v)
REQUEST.form[optional] = int(v)
except ValueError:
msgs.append('Unable to convert "%s" to a number' % v)
msgs = ', '.join(msgs)
Expand Down
4 changes: 2 additions & 2 deletions Products/ZenModel/RRDDataSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def zmanage_editProperties(self, REQUEST=None):
value = REQUEST['rrdmin']
if value != '':
try:
value = long(value)
value = int(value)
except ValueError:
messaging.IMessageSender(self).sendToBrowser(
'Error',
Expand All @@ -357,7 +357,7 @@ def zmanage_editProperties(self, REQUEST=None):
value = REQUEST['rrdmax']
if value != '':
try:
value = long(value)
value = int(value)
except ValueError:
messaging.IMessageSender(self).sendToBrowser(
'Error',
Expand Down
4 changes: 2 additions & 2 deletions Products/ZenModel/TemperatureSensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def temperatureCelsius(self, default=None):
if tempF is not None and not isnan(tempF):
tempC = (tempF - 32) / 9.0 * 5
if tempC is not None and not isnan(tempC):
return long(tempC)
return int(tempC)
return None
temperature = temperatureCelsius

Expand All @@ -87,7 +87,7 @@ def temperatureFahrenheit(self, default=None):
tempC = self.temperatureCelsius(default)
if tempC is not None and not isnan(tempC):
tempF = tempC * 9 / 5 + 32.0
return long(tempF)
return int(tempF)
return None

def temperatureCelsiusString(self):
Expand Down
6 changes: 3 additions & 3 deletions Products/ZenModel/ZenStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def incr(self):
if self.failstart == 0:
self.failstart = self.failincr = DateTime()
if self.status < 0: self.status = 1
delta = long((DateTime() - self.failincr) * 86400)
delta = int((DateTime() - self.failincr) * 86400)
if not self.failincr.isCurrentDay():
yavail = self._getYearlyData(self.failstart.year())
now = DateTime()
newdaydown = long((now.earliestTime() - now) * 86400)
newdaydown = int((now.earliestTime() - now) * 86400)
yesterdaydown = self.todaydown + (delta - newdaydown)
yavail.addDaily(yesterdaydown)
self.todaydown = 0
Expand Down Expand Up @@ -138,7 +138,7 @@ def getAvailPercent(self, start, end=None):
"""get availability for a date range as a float between 100.0 and 0.0"""
if self.status < 0: return -1
if not end: end = DateTime()
delta = long((end - start) * 86400.0)
delta = int((end - start) * 86400.0)
dt = self.getDownTime(start,end)
if dt < 0: return dt
return 100.0 - ((self.getDownTime(start, end) / delta)*100)
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenModel/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def _adjustToTimezone(self, millis, timezone):
"""
Convert event timestamp to timezone from user property.
"""
return long(isoToTimestamp(convertTimestampToTimeZone(
return int(isoToTimestamp(convertTimestampToTimeZone(
millis / 1000, timezone, "%Y-%m-%d %H:%M:%S"
))) * 1000

Expand Down
4 changes: 1 addition & 3 deletions Products/ZenRRD/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ def loadargs(obj, args):
if obj._properties[i]["type"] == "lines":
value = map(string.strip, arg.split(","))
att = "_" + att
elif obj._properties[i]["type"] == "int":
elif obj._properties[i]["type"] in ("int", "long"):
value = int(arg)
elif obj._properties[i]["type"] == "long":
value = long(arg)
elif obj._properties[i]["type"] == "float":
value = float(arg)
elif obj._properties[i]["type"] == "boolean":
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenReports/plugins/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def getCompositeColumns(self):
"percentUsed",
PythonColumnHandler(
# total == total is False if total is NaN
"((long(total) if total == total else total) * 8)"
"((int(total) if total == total else total) * 8)"
"* 100.0 / speed"
),
),
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenReports/tests/testInterfacePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def assertInterfaceRowIsCorrect(
interface.id
]
testTotal = testInputOctets + testOutputOctets
testPercentUsed = long(testTotal) * 8 * 100.0 / testSpeed
testPercentUsed = int(testTotal) * 8 * 100.0 / testSpeed
assertRecordIsCorrect(
test,
record,
Expand Down
12 changes: 7 additions & 5 deletions Products/ZenUtils/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ def resequence(context, objects, seqmap, origseq, REQUEST):
"""
if seqmap and origseq:
try:
origseq = tuple(long(s) for s in origseq)
origseq = tuple(int(s) for s in origseq)
seqmap = tuple(float(s) for s in seqmap)
except ValueError:
origseq = ()
Expand Down Expand Up @@ -1409,18 +1409,20 @@ def unsigned(v):
>>> str(unsigned(-1))
'4294967295'
>>> unsigned(1)
1L
1
>>> unsigned(1e6)
1000000L
1000000
>>> unsigned(1e10)
10000000000L
10000000000
>>> unsigned(0 - ((2 ** 32) - 1))
1
@param v: number
@type v: negative 32-bit number
@return: 2's complement unsigned value
@rtype: unsigned int
"""
v = long(v)
v = int(v)
if v < 0:
return int(ctypes.c_uint32(v).value)
return v
Expand Down
2 changes: 1 addition & 1 deletion Products/ZenUtils/jsonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def json(value, **kw):
If C{value} is callable, a decorated version of C{value} that serializes its
return value will be returned.
>>> value = (dict(a=1L), u"123", 123)
>>> value = (dict(a=1), u"123", 123)
>>> print json(value)
[{"a": 1}, "123", 123]
>>> @json
Expand Down
4 changes: 2 additions & 2 deletions Products/ZenUtils/tests/testNaturalSort.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def test(self):
'1000','824','770','666',
'633','619','1','991',
'77H','PIER-7','47',
'29','9','77L','433'
'29','9','77','433'
], [
'01', '1', '4','9','29',
'42','44','47','77H',
'77L','87','433','480',
'77','87','433','480',
'485','619','633','666',
'745','756','770','771',
'776','779','824','951',
Expand Down
4 changes: 2 additions & 2 deletions Products/Zuul/catalog/indexable.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ def idx_lastDecimalIp(self):
last_decimal_ip = None
if isip(self.id):
net = IPNetwork(ipunwrap(self.id))
first_decimal_ip = long(int(net.network))
last_decimal_ip = str(long(first_decimal_ip + math.pow(2, net.max_prefixlen - self.netmask) - 1))
first_decimal_ip = int(net.network)
last_decimal_ip = str(int(first_decimal_ip + math.pow(2, net.max_prefixlen - self.netmask) - 1))
return last_decimal_ip

class ProductIndexable(object):
Expand Down
2 changes: 1 addition & 1 deletion Products/Zuul/infos/component/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class FanInfo(ComponentInfo):
def rpm(self):
rpm = self.getFetchedDataPoint('rpm')
if rpm is not None and not isnan(rpm):
rpm = long(rpm)
rpm = int(rpm)
return rpm
2 changes: 1 addition & 1 deletion Products/Zuul/infos/component/powersupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ class PowerSupplyInfo(ComponentInfo):
def millivolts(self):
millivolts = self.getFetchedDataPoint('millivolts')
if millivolts is not None:
millivolts = long(millivolts)
millivolts = int(millivolts)
return millivolts

0 comments on commit 9668556

Please sign in to comment.