update script

This commit is contained in:
Dimitris Zlatanidis 2015-05-26 07:30:22 +03:00
parent 1ca087251a
commit 165773eaee

View file

@ -34,42 +34,27 @@ class Clean(object):
keep this script if you want to remove data some time. keep this script if you want to remove data some time.
""" """
def __init__(self): def __init__(self):
self.man_path = "/usr/man/man8/" self.files = [
self.bash_completion = "/etc/bash_completion.d/" "/usr/man/man8/slpkg.8.gz",
self.fish_completion = "/etc/fish/completions/" "/etc/bash_completion.d/slpkg.bash-completion",
self.conf_path = "/etc/slpkg/" "/etc/fish/completions/slpkg.fish"
self.log_path = "/var/log/slpkg/" ]
self.lib_path = "/var/lib/slpkg/" self.dirs = [
self.tmp_path = "/tmp/slpkg/" "/etc/slpkg/",
self.man_file = "slpkg.8.gz" "/var/log/slpkg/",
self.bash_completion_file = "slpkg.bash-completion" "/var/lib/slpkg/",
self.fish_completion_file = "slpkg.fish" "/tmp/slpkg/"
]
def start(self): def start(self):
if os.path.isfile(self.man_path + self.man_file): for f in self.files:
print("Remove man page --> {0}".format(self.man_file)) if os.path.isfile(f):
os.remove(self.man_path + self.man_file) print("Remove file --> {0}".format(f))
if os.path.isfile(self.bash_completion + self.bash_completion_file): os.remove(f)
print("Remove bash completion file --> {0}".format( for d in self.dirs:
self.bash_completion_file)) if os.path.exists(d):
os.remove(self.bash_completion + self.bash_completion_file) print("Remove directory --> {0}".format(d))
if os.path.isfile(self.fish_completion + self.fish_completion_file): shutil.rmtree(d)
print("Remove fish completion file --> {0}".format(
self.fish_completion_file))
os.remove(self.fish_completion + self.fish_completion_file)
if os.path.exists(self.conf_path):
print("Remove configuration directory --> {0}".format(
self.conf_path))
shutil.rmtree(self.conf_path)
if os.path.exists(self.log_path):
print("Remove log data directory --> {0}".format(self.log_path))
shutil.rmtree(self.log_path)
if os.path.exists(self.lib_path):
print("Remove library data directory --> {0}".format(self.lib_path))
shutil.rmtree(self.lib_path)
if os.path.exists(self.tmp_path):
print("Remove temponary directory --> {0}".format(self.tmp_path))
shutil.rmtree(self.tmp_path)
if __name__ == '__main__': if __name__ == '__main__':
Clean().start() Clean().start()