MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / disable_swap_linux

Function disable_swap_linux

bleachbit/Memory.py:75–94  ·  view source on GitHub ↗

Disable Linux swap and return list of devices

()

Source from the content-addressed store, hash-verified

73
74
75def disable_swap_linux():
76 """Disable Linux swap and return list of devices"""
77 if 0 == count_swap_linux():
78 return
79 logger.debug(_("Disabling swap."))
80 args = ["swapoff", "-a", "-v"]
81 (rc, stdout, stderr) = General.run_external(args)
82 if 0 != rc:
83 raise RuntimeError(stderr.replace("\n", ""))
84 devices = []
85 for line in stdout.split('\n'):
86 line = line.replace('\n', '')
87 if '' == line:
88 continue
89 ret = parse_swapoff(line)
90 if ret is None:
91 raise RuntimeError(f"Unexpected output:\nargs='{args}'\n"
92 f"stdout='{stdout}'\nstderr='{stderr}'")
93 devices.append(ret)
94 return devices
95
96
97def enable_swap_linux():

Callers 2

test_swap_off_swap_onMethod · 0.90
wipe_memoryFunction · 0.85

Calls 2

count_swap_linuxFunction · 0.85
parse_swapoffFunction · 0.85

Tested by 1

test_swap_off_swap_onMethod · 0.72