From 3fba0062078cc04eabb460ec1eb13a4739235199 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 7 Sep 2018 17:59:46 -0700 Subject: Update bare exceptions to specify Exception. This will keep us from accidentally catching program-exiting exceptions like KeyboardInterupt and SystemExit. --- contrib/inventory/collins.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'contrib/inventory/collins.py') diff --git a/contrib/inventory/collins.py b/contrib/inventory/collins.py index 8c7b36c9bc..b768f6b3f9 100755 --- a/contrib/inventory/collins.py +++ b/contrib/inventory/collins.py @@ -208,7 +208,7 @@ class CollinsInventory(object): break cur_page += 1 num_retries = 0 - except: + except Exception: self.log.error("Error while communicating with Collins, retrying:\n%s", traceback.format_exc()) num_retries += 1 return assets @@ -277,7 +277,7 @@ class CollinsInventory(object): # Locates all server assets from Collins. try: server_assets = self.find_assets() - except: + except Exception: self.log.error("Error while locating assets from Collins:\n%s", traceback.format_exc()) return False @@ -288,7 +288,7 @@ class CollinsInventory(object): ip_index = self._asset_get_attribute(asset, 'ANSIBLE_IP_INDEX') try: ip_index = int(ip_index) - except: + except Exception: self.log.error( "ANSIBLE_IP_INDEX attribute on asset %s not an integer: %s", asset, ip_index) @@ -350,7 +350,7 @@ class CollinsInventory(object): try: self.write_to_cache(self.cache, self.cache_path_cache) self.write_to_cache(self.inventory, self.cache_path_inventory) - except: + except Exception: self.log.error("Error while writing to cache:\n%s", traceback.format_exc()) return False return True @@ -388,7 +388,7 @@ class CollinsInventory(object): json_inventory = cache.read() self.inventory = json.loads(json_inventory) return True - except: + except Exception: self.log.error("Error while loading inventory:\n%s", traceback.format_exc()) self.inventory = {} @@ -402,7 +402,7 @@ class CollinsInventory(object): json_cache = cache.read() self.cache = json.loads(json_cache) return True - except: + except Exception: self.log.error("Error while loading host cache:\n%s", traceback.format_exc()) self.cache = {} -- cgit v1.2.1