Pull out indice and rename variable
This commit is contained in:
parent
5d519f2380
commit
d2c729f0ab
@ -38,19 +38,18 @@ class SwapModule(AbstractModule):
|
||||
|
||||
def _swap_location_check(self):
|
||||
output_swaps = subprocess.check_output(['cat', '/proc/swaps']).decode("UTF-8")
|
||||
final_list = list(output_swaps.split())
|
||||
swap_location = output_swaps.split()[5]
|
||||
try:
|
||||
print("Swap is located here:", final_list[5])
|
||||
self.swap_file = final_list[5]
|
||||
print("Swap is located here:", swap_location)
|
||||
self.swap_file = swap_location
|
||||
except IndexError:
|
||||
print("Swap file doesn´t exist!")
|
||||
return "NoSwap"
|
||||
|
||||
def _get_swap_size(self):
|
||||
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||
final_list = list(swap_size.split())
|
||||
swap_size = swap_size.split()[7]
|
||||
try:
|
||||
print("Swap is {}b big!".format(final_list[7]))
|
||||
print("Swap is {}b big!".format(swap_size))
|
||||
except IndexError:
|
||||
print("Swap file doesn´t exist!")
|
||||
|
||||
@ -69,10 +68,10 @@ class SwapModule(AbstractModule):
|
||||
|
||||
else:
|
||||
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||
final_list = list(swap_size.split())
|
||||
swap_size = swap_size.split()[7]
|
||||
print("")
|
||||
print("Swap already installed! You can resize it!")
|
||||
print("Curr. swap size: {}b".format(final_list[7]))
|
||||
print("Curr. swap size: {}b".format(swap_size))
|
||||
resize = input("How big should your swap become(numbers in Gigabyte)? ")
|
||||
resize_swapfile = "sudo swapoff /swapfile && " + \
|
||||
"sudo fallocate -l {}G /swapfile && ".format(resize) + \
|
||||
|
Loading…
Reference in New Issue
Block a user