slpkg/clean.py

62 lines
2 KiB
Python
Raw Normal View History

2015-05-26 05:51:43 +02:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
# clean.py file is part of slpkg.
# Copyright 2014-2015 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Slpkg is a user-friendly package manager for Slackware installations
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2015-05-28 05:07:13 +02:00
2015-05-26 05:51:43 +02:00
import os
import shutil
class Clean(object):
"""Clean all data like man page, log files, PACKAGES.TXT and
2015-06-05 13:42:52 +02:00
configuration files. This is useful if "slpkg" installed via
"pip" because pip uninstalls only Python packages and script
and not data. So if uninstall "# pip uninstall slpkg" after run
"# python clean.py" to remove all data and configuration file.
2015-05-26 06:09:46 +02:00
keep this script if you want to remove data some time.
2015-06-13 15:23:48 +02:00
NOTE: Run this script as root."""
2015-05-26 05:51:43 +02:00
def __init__(self):
2015-05-26 06:30:22 +02:00
self.files = [
"/usr/man/man8/slpkg.8.gz",
"/etc/bash_completion.d/slpkg.bash-completion",
"/etc/fish/completions/slpkg.fish"
]
self.dirs = [
"/etc/slpkg/",
"/var/log/slpkg/",
"/var/lib/slpkg/",
"/tmp/slpkg/"
]
2015-05-26 05:51:43 +02:00
def start(self):
2015-05-26 06:30:22 +02:00
for f in self.files:
if os.path.isfile(f):
print("Remove file --> {0}".format(f))
os.remove(f)
for d in self.dirs:
if os.path.exists(d):
print("Remove directory --> {0}".format(d))
shutil.rmtree(d)
2015-05-26 05:51:43 +02:00
2015-06-05 13:42:52 +02:00
if __name__ == "__main__":
2015-05-26 05:51:43 +02:00
Clean().start()