-
Notifications
You must be signed in to change notification settings - Fork 1
/
uninstall.py
64 lines (47 loc) · 1.66 KB
/
uninstall.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
#!/usr/bin/env python3
# coding: utf-8
import platform
import glob
import os
import shutil
import sys
os_type = platform.system()
if os_type == 'Linux':
path_list = [
'/usr/share/applications/yooz.desktop',
'/usr/bin/yooz']
# find yooz directories in /usr/lib/python3.6/site-packages/
pattern = os.path.join('/usr/lib/python3.6/site-packages/', 'yooz*')
for folder in glob.glob(pattern):
path_list.append(folder)
# find yooz directories in /usr/lib/python3.5/site-packages/
pattern = os.path.join('/usr/lib/python3.5/site-packages/', 'yooz*')
for folder in glob.glob(pattern):
path_list.append(folder)
elif os_type == 'FreeBSD' or os_type == 'OpenBSD':
path_list = [
'/usr/local/share/applications/yooz.desktop',
'/usr/local/bin/yooz']
# find yooz directories in /usr/lib/python3.6/site-packages/
pattern = os.path.join('/usr/local/lib/python3.6/site-packages/', 'yooz*')
for folder in glob.glob(pattern):
path_list.append(folder)
# find yooz directories in /usr/lib/python3.5/site-packages/
pattern = os.path.join('/usr/local/lib/python3.5/site-packages/', 'yooz*')
for folder in glob.glob(pattern):
path_list.append(folder)
else:
print('This script is for Linux and BSD')
sys.exit(1)
uid = os.getuid()
if uid != 0:
print('run this script as root.')
sys.exit(1)
for path in path_list:
if os.path.exists(path):
if os.path.isfile(path): # if path is for file
os.remove(path) # removing file
else:
shutil.rmtree(path) # removing folder
print(str(path) + ' is removed!')
print('uninstallation is complete!')