-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli.py
91 lines (83 loc) · 2.78 KB
/
cli.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from function import *
from argparse import ArgumentParser
from function import __doc__ as doc
from sys import version_info , exit
from os import popen
if version_info[0] > 2:
exit("Only Python2.7 is supported")
########### Arguements of the program ##############
parser = ArgumentParser()
parser.add_argument("-p", "--path", dest="path", required=True, help="Path to the app you want to search for related files")
parser.add_argument("-c", "--custom-path", nargs = '*',dest = "custom" , help = " Custom Paths where you want to search ")
args = parser.parse_args()
#####################################################
####Modify args.path#######
if args.path[0]!="/":
if args.path[0] == "~":
args.path = os.getenv("HOME") + a[1:len(a)]
else:
args.path = os.getcwd() + "/" + args.path
if not args.custom:
print(doc)
print("\n")
print("macuninstaller is going to do an \033[1m\033[31mUsual Scan\033[0m")
print("This may take time")
files , folders = thread_scanner(args.path)
files = cleanup(files)
folders = cleanup(folders)
chosen_files = selector(files, "Files")
if chosen_files == 0:
exit()
chosen_folders = selector(folders, "Folders")
if chosen_folders == 0:
exit()
files_to_delete = " "
folders_to_delete = " \"" + args.path + "\" "
for path in chosen_files:
files_to_delete += " \"" + path + "\" "
for path in chosen_folders:
folders_to_delete += " \"" + path + "\" "
print("Enter your password to delete everything you chose")
cmd = "sudo rm " + files_to_delete + " ; sudo rm -rf " + folders_to_delete + " ;"
a = popen(cmd)
print a.read()
a.close()
for stuff in chosen_files:
if os.path.isfile(stuff):
print("Files still exists "+ stuff)
for stuff in chosen_folders:
if os.path.isdir(stuff):
print("Folder still exists "+ stuff)
print("Have a good day!")
else:
print(doc)
print("\n")
print("macuninstaller is going to do a \033[1m\033[31mCustom Scan\033[0m")
print("This may take time")
files , folders = thread_custom_scanner(args.path , args.custom)
files = cleanup(files)
folders = cleanup(folders)
chosen_files = selector(files, "Files")
if chosen_files == 0:
exit()
chosen_folders = selector(folders, "Folders")
if chosen_folders == 0:
exit()
files_to_delete = " "
folders_to_delete = " \"" + args.path + "\" "
for path in chosen_files:
files_to_delete += " \"" + path + "\" "
for path in chosen_folders:
folders_to_delete += " \"" + path + "\" "
print("Enter your password to delete everything you chose")
cmd = "sudo rm " + files_to_delete + " ; sudo rm -rf " + folders_to_delete + " ;"
a = popen(cmd)
print a.read()
a.close()
for stuff in chosen_files:
if os.path.isfile(stuff):
print("Files still exists "+ stuff)
for stuff in chosen_folders:
if os.path.isdir(stuff):
print("Folder still exists "+ stuff)
print("Have a good day!")