Inverse if case for better readability

Remove unnecessary line
This commit is contained in:
Lucas Noki 2020-01-25 02:10:12 +01:00
parent dcb5681aa3
commit 035e4ce6ae

View File

@ -55,18 +55,7 @@ class SwapModule(AbstractModule):
def _create_resize_swap(self):
output_swapon = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
if not output_swapon:
size = input("How big should the swap be (numbers in Gigabyte)? ")
create_swapfile = "sudo fallocate -l {}G /swapfile && ".format(size) + \
"sudo chmod 600 /swapfile && " + \
"sudo mkswap /swapfile && " + \
"sudo swapon /swapfile"
subprocess.call(create_swapfile, shell=True)
output_free = subprocess.check_output(['free', '-h']).decode("UTF-8")
print(output_free.strip())
else:
if output_swapon:
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
swap_size = swap_size.split()[7]
print("")
@ -81,6 +70,17 @@ class SwapModule(AbstractModule):
output_free = subprocess.check_output(['free', '-h']).decode("UTF-8")
print(output_free.strip())
else:
size = input("How big should the swap be (numbers in Gigabyte)? ")
create_swapfile = "sudo fallocate -l {}G /swapfile && ".format(size) + \
"sudo chmod 600 /swapfile && " + \
"sudo mkswap /swapfile && " + \
"sudo swapon /swapfile"
subprocess.call(create_swapfile, shell=True)
output_free = subprocess.check_output(['free', '-h']).decode("UTF-8")
print(output_free.strip())
def _make_swap_persistent(self):
self._swap_location_check()
backup_fstab = "sudo cp /etc/fstab /etc/fstab.bak"
@ -91,7 +91,6 @@ class SwapModule(AbstractModule):
def _show_swapiness(self):
get_swapiness = "cat /proc/sys/vm/swappiness"
subprocess.call(get_swapiness, shell=True)
def _adjust_swapiness_temp(self):