Simplify if statements
This commit is contained in:
parent
faac5d22be
commit
e25c3f16d6
@ -83,13 +83,12 @@ class SwapModule(AbstractModule):
|
|||||||
|
|
||||||
def _make_swap_persistent(self):
|
def _make_swap_persistent(self):
|
||||||
swap_location = self._get_swap_location()
|
swap_location = self._get_swap_location()
|
||||||
persistence_entry = self._check_fstab_entry()
|
|
||||||
if swap_location is None:
|
if swap_location is None:
|
||||||
print("Swap file doesn't exist!")
|
print("Swap file doesn't exist!")
|
||||||
return
|
return
|
||||||
backup_fstab = "sudo cp /etc/fstab /etc/fstab.bak"
|
backup_fstab = "sudo cp /etc/fstab /etc/fstab.bak"
|
||||||
enable_persistence = "echo '{} none swap sw 0 0' | sudo tee -a /etc/fstab".format(swap_location)
|
enable_persistence = "echo '{} none swap sw 0 0' | sudo tee -a /etc/fstab".format(swap_location)
|
||||||
if persistence_entry is True:
|
if self._check_fstab_entry():
|
||||||
print("Swap is already persistent!")
|
print("Swap is already persistent!")
|
||||||
else:
|
else:
|
||||||
subprocess.call(backup_fstab, shell=True)
|
subprocess.call(backup_fstab, shell=True)
|
||||||
@ -126,7 +125,7 @@ class SwapModule(AbstractModule):
|
|||||||
return
|
return
|
||||||
disable_swapfile = "sudo swapoff {} && ".format(swap_location) + \
|
disable_swapfile = "sudo swapoff {} && ".format(swap_location) + \
|
||||||
"sudo rm {}".format(swap_location)
|
"sudo rm {}".format(swap_location)
|
||||||
if self._check_fstab_entry() is True:
|
if self._check_fstab_entry():
|
||||||
with open("/etc/fstab", "r") as fstab_out:
|
with open("/etc/fstab", "r") as fstab_out:
|
||||||
content = fstab_out.readlines()
|
content = fstab_out.readlines()
|
||||||
with open("/etc/fstab", "w") as fstab_in:
|
with open("/etc/fstab", "w") as fstab_in:
|
||||||
|
Loading…
Reference in New Issue
Block a user