-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
45 lines (32 loc) · 1.42 KB
/
setup.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
from sys import executable
from subprocess import check_call
import os
import sqlite3
def install() -> None:
# Takes the list of modules to be installed from requirements.txt and installs them
check_call([executable, "-m", "pip", "install", "-r", "requirements.txt"])
create_dirs()
return
def create_dirs() -> None:
# Create the "assets/history" directories if they do not exist
print("Creating save directories.")
os.makedirs("assets/history", exist_ok=True)
print("assets/history done.")
os.makedirs("assets/images", exist_ok=True)
print("assets/images done.")
if not os.path.exists("assets/history/history.db"):
print("Creating sqlite database.")
open(r"assets\history\history.db", "w")
history = sqlite3.connect(r"assets\history\history.db")
cursor = history.cursor()
cursor.execute("CREATE TABLE history (\n\tactions_id INTEGER NOT NULL,\n\tJSON TEXT NOT NULL,\n\tPRIMARY KEY (actions_id)\n)")
history.commit()
history.close()
print("Sqlite database created successfully.")
print("creating json file.")
with open(r"assets\history\history.json", "w") as f:
f.write("[]")
print("json file created successfully.")
if __name__ == "__main__":
install()
# recommended to run this file if it is the first time running the program