PingdomLib
PingdomLib copied to clipboard
likelihood of py3 support?
Python noob here. Is this code likely to be updated to work with Python3?
I get various errors trying to use it with Python 3.6.2. Some are simple and appear to be related to the removal of list.iteritems
and dict.iterkeys/values
in Python3; I've fixed locally and that code now appears to do the right thing. Not sure what to do with the below, however:
def __addDetails__(self, checkinfo):
"""Fills attributes from a dictionary, uses special handling for the
'type' key"""
# Auto-load instance attributes from passed in dictionary
for key in checkinfo:
if key == 'type':
if checkinfo[key] in checktypes:
self.type = checkinfo[key]
else:
# Take key from type dict, convert to string for type
self.type = checkinfo[key].keys().next()
# Take value from type dict, store to member of new attrib
object.__setattr__(self, self.type,
checkinfo[key].values().next())
else:
# Store other key value pairs as attributes
object.__setattr__(self, key, checkinfo[key])
The error I get is
>>> checks[0].getDetails()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pingdomlib/check.py", line 178, in getDetails
self.__addDetails__(response.json()['check'])
File "/usr/local/lib/python3.6/site-packages/pingdomlib/check.py", line 155, in __addDetails__
self.type = checkinfo[key].keys().next()
AttributeError: 'dict_keys' object has no attribute 'next'
Hi @indigoid ! I'm glad you've picked up Python and I hope you're enjoying it :smile:
I haven't used Pingdom myself in a few years and have not updated the library much as a result. I'd say the likelyhood of this working on Python 3 before you posted this issue was next to none, but since you mentioned it I will try to find some time during the next few weeks to try to ensure it's py3 compatible.
If someone submits fixes to compatibility before I get it done I will gladly merge that code in!