-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquicksetup.py
66 lines (53 loc) · 1.83 KB
/
quicksetup.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
import os
if __name__ == "__main__":
## Write the settings.py file that we do not git for security reasons
with open("preflib/local_settings.py", "w") as f:
f.write(
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'thisissecret'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'preflib.db'),
}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache', ## To be changed if you actually want to cache
'LOCATION': os.path.join(BASE_DIR, 'cache/'),
'TIMEOUT': str(60 * 60 * 12)
}
}
STATIC_ROOT = "static/"
# Path to the unix convert command for the image handling
CONVERT_PATH = 'convert'
"""
)
f.close()
## Create the migration folder and run the initial migration to set up the
## database (a simple SQLlite db here since it should be only use to play around).
try:
os.makedirs(os.path.join("preflibapp", "migrations"))
except:
pass
with open(os.path.join("preflibapp", "migrations", "__init__.py"), "w") as f:
f.write("")
f.close()
os.system("python3 manage.py makemigrations")
os.system("python3 manage.py migrate")
## Initialize the website
os.system("python3 manage.py initializedb")
os.system("python3 manage.py updatepapers")
os.system("python3 manage.py collectstatic")
## Set everything up to add data
try:
os.makedirs(os.path.join("preflibapp", "static", "datatoadd"))
except:
pass