Add get swap size option, Add get swap location option
Remove unnecessary comments Correct size output
This commit is contained in:
parent
fdd1c48bac
commit
526cfda6a8
@ -11,7 +11,7 @@ class SwapModule(AbstractModule):
|
||||
|
||||
def run(self):
|
||||
|
||||
actions = ["Create/Resize", "Delete"]
|
||||
actions = ["Create/Resize", "Delete", "Get location", "Get swap size"]
|
||||
menu = [
|
||||
{
|
||||
'type': 'list',
|
||||
@ -25,8 +25,11 @@ class SwapModule(AbstractModule):
|
||||
self.create_resize_swap()
|
||||
elif selected_action is "Delete":
|
||||
self.delete_swap()
|
||||
elif selected_action is "Get location":
|
||||
self.swap_location_check()
|
||||
elif selected_action is "Get swap size":
|
||||
self.get_swap_size()
|
||||
|
||||
# Check default swap location
|
||||
def swap_location_check(self) -> None:
|
||||
output_swaps = subprocess.check_output(['cat', '/proc/swaps']).decode("UTF-8")
|
||||
li = list(output_swaps.split())
|
||||
@ -36,7 +39,15 @@ class SwapModule(AbstractModule):
|
||||
self.swap_file = final_list[5]
|
||||
except IndexError:
|
||||
print("Swap file doesn´t exist!\n")
|
||||
# End of location check
|
||||
|
||||
def get_swap_size(self) -> None:
|
||||
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||
li = list(swap_size.split())
|
||||
final_list = li
|
||||
try:
|
||||
print("Swap is {}b big!".format(final_list[7]))
|
||||
except IndexError:
|
||||
print("Swap file doesn´t exist!")
|
||||
|
||||
def create_resize_swap(self):
|
||||
output_swapon = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||
|
Loading…
Reference in New Issue
Block a user