Skip to content

Commit 02e2055

Browse files
Uninstall (closes #55)
1 parent 35b7523 commit 02e2055

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

installer/main.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import io
33
import sys
4+
import shutil
45
import zipfile
56
import requests
67
import threading
@@ -35,7 +36,7 @@ def browse():
3536
path_entry.insert(0, customtkinter.filedialog.askdirectory())
3637

3738

38-
def install():
39+
def prepare(target):
3940
global progress_bar
4041
path = path_entry.get()
4142
try:
@@ -53,13 +54,14 @@ def install():
5354
path_entry.configure(state=customtkinter.DISABLED)
5455
browse_button.configure(state=customtkinter.DISABLED)
5556
install_button.destroy()
57+
uninstall_button.destroy()
5658
progress_bar = customtkinter.CTkProgressBar(app, determinate_speed=50 / 2)
5759
progress_bar.grid(column=0, row=1, columnspan=2, padx=5, pady=5)
5860
progress_bar.set(0)
59-
threading.Thread(target=_install, daemon=True, args=(path, )).start()
61+
threading.Thread(target=target, daemon=True, args=(path, )).start()
6062

6163

62-
def _install(path):
64+
def install(path):
6365
to_zip(
6466
requests.get(
6567
f"https://builds.bepinex.dev/projects/bepinex_be/{BEPINEX}.zip"
@@ -77,8 +79,40 @@ def _install(path):
7779
)
7880

7981

82+
def uninstall(path):
83+
dirs = [
84+
"BepInEx",
85+
"dotnet",
86+
]
87+
files = [
88+
".doorstop_version",
89+
"changelog.txt",
90+
"doorstop_config.ini",
91+
"winhttp.dll", # windows
92+
"libdoorstop.so", # linux
93+
"libdoorstop.dylib", # mac
94+
"run_bepinex.sh", # linux + mac
95+
]
96+
for dir in dirs:
97+
shutil.rmtree(path + "/" + dir, True)
98+
progress_bar.step()
99+
for file in files:
100+
try:
101+
os.remove(path + "/" + file)
102+
except FileNotFoundError:
103+
...
104+
progress_bar.step()
105+
customtkinter.CTkButton(app, text="Quit", command=quit).grid(
106+
column=0, row=2, columnspan=2, padx=5, pady=5
107+
)
108+
109+
80110
def launch():
81111
os.startfile("steam://rungameid/874390")
112+
quit()
113+
114+
115+
def quit():
82116
app.destroy()
83117
sys.exit()
84118

@@ -93,10 +127,14 @@ def launch():
93127
app, placeholder_text="Game path", width=228)
94128
browse_button = customtkinter.CTkButton(
95129
app, text="Browse", command=browse, width=1)
96-
install_button = customtkinter.CTkButton(app, text="Install", command=install)
130+
install_button = customtkinter.CTkButton(
131+
app, text="Install", command=lambda: prepare(install))
132+
uninstall_button = customtkinter.CTkButton(
133+
app, text="Uninstall", command=lambda: prepare(uninstall))
97134

98135
path_entry.grid(column=0, row=0, padx=5, pady=5)
99136
browse_button.grid(column=1, row=0, padx=(0, 5), pady=5)
100137
install_button.grid(column=0, row=1, columnspan=2, padx=5, pady=5)
138+
uninstall_button.grid(column=0, row=2, columnspan=2, padx=5, pady=5)
101139

102140
app.mainloop()

0 commit comments

Comments
 (0)