Remove if-"hell" in adjust swappiness

This commit is contained in:
Marcel Schwarz 2020-01-20 22:33:50 +01:00
parent d3e2c99198
commit e573118b38

View File

@ -104,29 +104,24 @@ class SwapModule(AbstractModule):
subprocess.call(get_swapiness, shell=True)
def adjust_swapiness_temp(self):
actions = ["Light", "Default", "Aggressive"]
actions = {
"Light": 25,
"Default": 60,
"Aggressive": 100
}
menu = [
{
'type': 'list',
'message': 'Select action',
'name': 'action',
'choices': list(map(lambda x: {"name": x}, actions))
'choices': list(map(lambda x: {"name": x}, actions.keys()))
}
]
selected_swapiness = prompt(menu)['action']
if selected_swapiness == "Light":
adjust = "sudo sysctl vm.swappiness=25"
subprocess.call(adjust, shell=True)
print("Temporary swapiness is 25")
elif selected_swapiness == "Default":
adjust = "sudo sysctl vm.swappiness=60"
subprocess.call(adjust, shell=True)
print("Temporary swapiness is 60")
elif selected_swapiness == "Aggressive":
adjust = "sudo sysctl vm.swappiness=100"
subprocess.call(adjust, shell=True)
print("Temporary swapiness is 100")
adjust = "sudo sysctl vm.swappiness=" + str(actions[selected_swapiness])
subprocess.call(adjust, shell=True)
print("Temporary swapiness is " + str(actions[selected_swapiness]))
def delete_swap(self):
self.swap_location_check()