-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
47 lines (37 loc) · 984 Bytes
/
run.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
import subprocess
import sys
import os
from ui.ui import App
from config import dl_path
def run():
# making directories if not there
try:
os.mkdir(f"{dl_path}")
except FileExistsError:
pass
try:
os.mkdir(f"{dl_path}\\mp4")
except FileExistsError:
pass
try:
os.mkdir(f"{dl_path}\\mp3")
except FileExistsError:
pass
# activating app
app = App()
app.display_downloads()
app.initialize_download_details()
def check_for_restart():
if app.restart:
print('restarting...')
# Get the command used to run the current program
command = [sys.executable] + sys.argv
# Spawn a new process with the same command
subprocess.Popen(command)
# Close the current process
sys.exit(0)
app.after(500, check_for_restart)
check_for_restart()
app.mainloop()
if __name__ == '__main__':
run()