1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
from catalyst import log
from catalyst.support import countdown
from catalyst.fileops import clear_dir
class ClearBase(object):
"""
This class does all of clearing after task completion
"""
def __init__(self, myspec):
self.settings = myspec
self.resume = None
def clear_autoresume(self):
""" Clean resume points since they are no longer needed """
if "autoresume" in self.settings["options"]:
log.notice('Removing AutoResume Points ...')
self.resume.clear_all()
def remove_autoresume(self):
""" Rmove all resume points since they are no longer needed """
if "autoresume" in self.settings["options"]:
log.notice('Removing AutoResume ...')
self.resume.clear_all(remove=True)
def clear_chroot(self):
self.chroot_lock.unlock()
log.notice('Clearing the chroot path ...')
clear_dir(self.settings["chroot_path"], 0o755, True)
def remove_chroot(self):
self.chroot_lock.unlock()
log.notice('Removing the chroot path ...')
clear_dir(self.settings["chroot_path"], 0o755, True, remove=True)
def clear_packages(self, remove=False):
if "pkgcache" in self.settings["options"]:
log.notice('purging the pkgcache ...')
clear_dir(self.settings["pkgcache_path"], remove=remove)
def clear_kerncache(self, remove=False):
if "kerncache" in self.settings["options"]:
log.notice('purging the kerncache ...')
clear_dir(self.settings["kerncache_path"], remove=remove)
def purge(self, remove=False):
countdown(10,"Purging Caches ...")
if any(k in self.settings["options"] for k in ("purge",
"purgeonly", "purgetmponly")):
log.notice('purge(); clearing autoresume ...')
self.clear_autoresume()
log.notice('purge(); clearing chroot ...')
self.clear_chroot()
if "purgetmponly" not in self.settings["options"]:
log.notice('purge(); clearing package cache ...')
self.clear_packages(remove)
log.notice('purge(); clearing kerncache ...')
self.clear_kerncache(remove)
|