diff --git a/jss/auth.py b/jss/auth.py index 637e0b7..21ec30b 100644 --- a/jss/auth.py +++ b/jss/auth.py @@ -58,7 +58,7 @@ def handle_401(self, r, **kwargs): # type: (requests.Response, dict) -> request :param kwargs: :return: """ - if r.status_code is not 401: + if r.status_code != 401: return r logger.debug("Server returned HTTP 401, getting a new token") diff --git a/jss/jssobject.py b/jss/jssobject.py index d747ddc..9a8c3f2 100644 --- a/jss/jssobject.py +++ b/jss/jssobject.py @@ -157,7 +157,7 @@ def _reset_data(self, updated_data): """Clear all children of base element and replace with update""" self.clear() # Convert all incoming data to PrettyElements. - for child in updated_data.getchildren(): + for child in list(updated_data): if not isinstance(child, PrettyElement): child = PrettyElement(child) self._children.append(child) @@ -767,7 +767,7 @@ def add_object_to_path(self, obj, location): """ location = self._handle_location(location) location.append(obj.as_list_data()) - results = [item for item in location.getchildren() if + results = [item for item in list(location) if item.findtext("id") == obj.id][0] return results @@ -782,10 +782,10 @@ def remove_object_from_list(self, obj, list_element): list_element = self._handle_location(list_element) if isinstance(obj, Container): - results = [item for item in list_element.getchildren() if + results = [item for item in list(list_element) if item.findtext("id") == obj.id] elif isinstance(obj, (int, string_types)): - results = [item for item in list_element.getchildren() if + results = [item for item in list(list_element) if item.findtext("id") == str(obj) or item.findtext("name") == obj] @@ -957,7 +957,7 @@ def has_member(self, device_object): raise ValueError return len([device for device in self.findall(container_search) if - device.findtext("id") == device_object.id]) is not 0 + device.findtext("id") == device_object.id]) != 0 # class Scoped(Container):