forked from rickyrockrat/parcellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall-pre-0.5.py
70 lines (56 loc) · 2.12 KB
/
uninstall-pre-0.5.py
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
70
#!/usr/bin/env python
# Copyright (C) 2007-2008 by Xyhthyx <xyhthyx@gmail.com>
# This file is part of Parcellite.
# Parcellite 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.
# Parcellite 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/>.
# Run this script as root to uninstall Parcellite v0.4 or less
import os
import sys
# Remove current working directory so python
# doesn't import local parcellite.py file
sys.path.remove(os.getcwd())
try:
import parcellite
except ImportError:
print 'Parcellite is not installed.'
sys.exit(1)
if not os.path.exists('/usr/bin/parcellite'):
print 'Parcellite is not installed.'
sys.exit(1)
elif not os.environ['LOGNAME'] == 'root':
print 'Please run this script as root.'
sys.exit(1)
files = ['/etc/xdg/autostart/parcellite-startup.desktop', '/usr/share/applications/parcellite.desktop', '/usr/share/parcellite/gui/preferences.glade', '/usr/share/parcellite/gui/clipboard.glade', '/usr/bin/parcellite']
dirs = ['/usr/share/parcellite/gui', '/usr/share/parcellite']
# Remove files
for each in files:
if os.path.exists(each):
try:
os.remove(each)
print 'Removing-> ' + each
except:
pass
# Remove directories
for each in dirs:
if os.path.exists(each):
try:
os.rmdir(each)
print 'Removing-> ' + each
except:
pass
# Remove module
try:
os.remove(os.path.join(os.path.dirname(parcellite.__file__), 'parcellite.py'))
print 'Removing-> ' + os.path.join(os.path.dirname(parcellite.__file__), 'parcellite.py')
os.remove(os.path.join(os.path.dirname(parcellite.__file__), 'parcellite.pyc'))
print 'Removing-> ' + os.path.join(os.path.dirname(parcellite.__file__), 'parcellite.pyc')
except:
pass