-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto.py
76 lines (55 loc) · 2.16 KB
/
auto.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
import os
import sys
import random
import shutil
from commands.config import main as config
from commands.mysql_config import main as mysql_config
from commands.security import main as security
def main():
if len(sys.argv) == 1:
os.system('cls')
if os.path.isdir('./env'):
try:
shutil.rmtree('./env')
except:
print("\nplease first remove env folder and then try again\n")
return
# Chcking if some packages are installed
print("Checking if python is installed\n")
os.system("python --version")
print("\nChecking if mysql is installed\n")
os.system("mysql --version")
print("\nChecking if pip3 is installed\n")
os.system("pip --version")
# Creating a virtual environment
print("\nCreating a virtual environment\n")
os.system("python -m venv env")
print("\n\nIf there is no problem on top log, Run this command: \n\n.\\env\\Scripts\\activate && python auto.py windows")
return
elif sys.argv[1] == "windows" or sys.argv[1] == "window":
os.system('cls')
# installing requirements
os.system("pip install wheel && pip install --upgrade setuptools wheel")
os.system("pip install -r requirements.txt")
print("\n\nThe installation process is done")
print("After checking the log, if there is no problem, you can run the bot with \"python main.py\" command")
print("Press any button to continue to mysql configuration")
input()
secret = "SECRET_KEY="
secret = secret + "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])
f = open(".env", "w")
f.write(secret)
f.close()
mysql_config()
f = open("config.ini", "w")
f.close()
security()
config()
# Migration database
print("Database migration")
os.system("python manage.py makemigrations users groups")
os.system("python manage.py migrate")
# Run Bot
os.system("python main.py")
if __name__ == "__main__":
main()