From de6b0917e81a8aa6c33bcbdaabff1ae3a2c5da9b Mon Sep 17 00:00:00 2001 From: Lucas Noki Date: Sat, 25 Jan 2020 02:38:12 +0100 Subject: [PATCH] put index access in try block --- modules/swap/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swap/module.py b/modules/swap/module.py index 9f7d370..49d3ef7 100644 --- a/modules/swap/module.py +++ b/modules/swap/module.py @@ -38,8 +38,8 @@ class SwapModule(AbstractModule): def _swap_location_check(self): output_swaps = subprocess.check_output(['cat', '/proc/swaps']).decode("UTF-8") - swap_location = output_swaps.split()[5] try: + swap_location = output_swaps.split()[5] print("Swap is located here:", swap_location) self.swap_file = swap_location except IndexError: @@ -47,8 +47,8 @@ class SwapModule(AbstractModule): def _get_swap_size(self): swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8") - swap_size = swap_size.split()[7] try: + swap_size = swap_size.split()[7] print("Swap is {}b big!".format(swap_size)) except IndexError: print("Swap file doesn´t exist!")