-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
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'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels