Inverse if case for better readability
Remove unnecessary line
This commit is contained in:
parent
dcb5681aa3
commit
035e4ce6ae
@ -55,18 +55,7 @@ class SwapModule(AbstractModule):
|
|||||||
|
|
||||||
def _create_resize_swap(self):
|
def _create_resize_swap(self):
|
||||||
output_swapon = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
output_swapon = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||||
if not output_swapon:
|
if 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:
|
|
||||||
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
|
||||||
swap_size = swap_size.split()[7]
|
swap_size = swap_size.split()[7]
|
||||||
print("")
|
print("")
|
||||||
@ -81,6 +70,17 @@ class SwapModule(AbstractModule):
|
|||||||
output_free = subprocess.check_output(['free', '-h']).decode("UTF-8")
|
output_free = subprocess.check_output(['free', '-h']).decode("UTF-8")
|
||||||
print(output_free.strip())
|
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):
|
def _make_swap_persistent(self):
|
||||||
self._swap_location_check()
|
self._swap_location_check()
|
||||||
backup_fstab = "sudo cp /etc/fstab /etc/fstab.bak"
|
backup_fstab = "sudo cp /etc/fstab /etc/fstab.bak"
|
||||||
@ -91,7 +91,6 @@ class SwapModule(AbstractModule):
|
|||||||
|
|
||||||
def _show_swapiness(self):
|
def _show_swapiness(self):
|
||||||
get_swapiness = "cat /proc/sys/vm/swappiness"
|
get_swapiness = "cat /proc/sys/vm/swappiness"
|
||||||
|
|
||||||
subprocess.call(get_swapiness, shell=True)
|
subprocess.call(get_swapiness, shell=True)
|
||||||
|
|
||||||
def _adjust_swapiness_temp(self):
|
def _adjust_swapiness_temp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user