-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
52 lines (42 loc) · 1.96 KB
/
start.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
import os, sys, platform
script_dir=os.path.dirname(os.path.realpath(__file__))
try: from colorama import init, Fore, Style
except:
os.system('pip install colorama')
os.system(F'python {script_dir}/start.py')
quiet=False
if len(sys.argv) > 1:
if sys.argv[1] == 'quiet': quiet=True
init()
print()
infoMsg = Fore.GREEN + "[LAUNCH] " + Style.RESET_ALL
warningMsg = Fore.YELLOW + "[LAUNCH] " + Style.RESET_ALL
startscriptMsg = Fore.YELLOW + "--------------------" + Style.RESET_ALL
endScriptMsg = Fore.BLUE + "--------------------" + Style.RESET_ALL
print(infoMsg + "Tak będą wyglądać informacje,")
print(Fore.YELLOW + "[LAUNCH]" + Style.RESET_ALL + " tak ostrzeżenia,")
print(Fore.RED + "[LAUNCH]" + Style.RESET_ALL + " a tak błędy.")
print()
# Update
print(infoMsg + "Aktualizowanie kodu używając polecenia " + Fore.YELLOW + "git pull")
print(startscriptMsg)
try: os.system(F'cd {script_dir}&& git pull')
except: print(warningMsg + "Aktualizowanie kodu nieudane - git niewykryty")
print(endScriptMsg)
print()
print(infoMsg + "Aktualizowanie bibliotek używając polecenia " + Fore.YELLOW + "pip install -U")
print(startscriptMsg)
os.system(F"pip install -r {script_dir}/requirements.txt -U")
print(endScriptMsg)
print()
# Run
if quiet:
print(infoMsg + "Uruchamianie programu" + Fore.RED + " w tle" + Style.RESET_ALL + " - " + Fore.YELLOW + "main.py")
if platform.system() == 'Windows': pass# os.system(F'setsid python {script_dir}/app/main.py >nul 2>&1 < nul &')
else: os.system(F'setsid python {script_dir}/app/main.py >/dev/null 2>&1 < /dev/null &')
else:
print(infoMsg + "Uruchamianie programu - " + Fore.YELLOW + "main.py" + Style.RESET_ALL + " - użyj " + Fore.RED + "Ctrl + C" + Style.RESET_ALL + ", aby zakończyć (może to chwilę potrwać)")
print(startscriptMsg)
if platform.system() == 'Windows': os.system(F'python {script_dir}/app/main.py 2> nul')
else: os.system(F'python {script_dir}/app/main.py 2> /dev/null')
print(endScriptMsg)