-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlauncher.py
60 lines (46 loc) · 1.6 KB
/
launcher.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
"""Runs bot"""
import os
import subprocess
import sys
# USEFUL FUNCTIONS
if sys.platform == "win32" or sys.platform == "win64":
def clear():
return os.system("cls")
else:
def clear():
return os.system("clear")
def check_updates():
"""Checks if there are some available updates for the bot"""
subprocess.call("git fetch",
stdout=open(os.devnull, 'w'),
stderr=subprocess.STDOUT,
shell=True)
result = subprocess.check_output("git status", shell=True)
if "Your branch is behind" in str(result):
answer = input(
"The bot isn't up-to-date, please type 'yes' to update it!\n\n> ")
if answer.upper() == "YES":
os.system("git pull")
def ask_user():
"""Asks user for installing requirements/launching the bot"""
answer = ""
while answer != "3":
clear()
answer = input("What do you want to do?\n\n" +
"1. Install & update requirements\n" +
"2. Launch the bot\n" + "3. Quit\n\n> ")
if answer == "1":
install_requirements()
elif answer == "2":
from bot import run_bot
run_bot()
def install_requirements():
"""Installs requirements"""
subprocess.call("python -m pip install -U -r requirements.txt",
stdout=open(os.devnull, 'w'),
stderr=subprocess.STDOUT,
shell=True)
if __name__ == "__main__":
check_updates()
clear()
ask_user()