|
1 | 1 | import json |
2 | 2 | import os |
| 3 | +import re |
3 | 4 | import sys |
4 | 5 | from configuration import Config, Constants |
5 | 6 | from utils.printing import Logger |
|
8 | 9 | import shutil |
9 | 10 | import colorama |
10 | 11 | log = Logger() |
| 12 | +import _locale |
| 13 | +_locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8']) |
11 | 14 |
|
12 | 15 | # Quick-start development settings - unsuitable for production |
13 | 16 | # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ |
|
16 | 19 | SECRET_KEY = "0px^lshd1lsf6uq#%90lre3$iqkz9=i7a0ko2_83b$n@=&(*d5" |
17 | 20 |
|
18 | 21 | # SECURITY WARNING: don't run with debug turned on in production! |
19 | | -DEBUG = True |
| 22 | +DEBUG = False |
20 | 23 | LOGGING_CONFIG = None |
21 | 24 | # SILENCED_SYSTEM_CHECKS = ["fields.W340"] |
22 | 25 | ALLOWED_HOSTS = ['*'] |
|
38 | 41 | } |
39 | 42 | } |
40 | 43 |
|
41 | | - |
42 | | -# First of all, check if the db is located in the old folder (root) |
43 | | - |
44 | | -if not 'migrat' or "passcheck" in str(sys.argv[1:]): # Check if the user runs migration. Don't execute this if that's the case. |
45 | | - src = Config().root_path |
46 | | - dest = os.path.join(Config().database_dir) |
47 | | - okmoved = True |
48 | | - |
49 | | - try: |
50 | | - if sys.frozen or sys.importers: |
51 | | - compiled = True |
52 | | - except AttributeError: |
53 | | - compiled = False |
54 | | - |
55 | | - if not os.path.isfile(os.path.join(src, "db.sqlite3")) and not os.path.isfile(os.path.join(dest, "db.sqlite3")): |
56 | | - print("\n") |
57 | | - print("No database") |
58 | | - print(f"There is no database installed at: {os.path.join(dest, 'db.sqlite3')}") |
59 | | - print( |
60 | | - "Please run the below commands from your YAPO main directory to create the database,\nor place your database at the above location.\n\nConsult the guide or website for help.") |
61 | | - print("\nCOMMAND(S) TO RUN:\n") |
62 | | - if not compiled: |
63 | | - print("python manage.py makemigrations") |
64 | | - print("python manage.py migrate\n") |
65 | | - else: |
66 | | - print('migrate.exe (or \"migrate\"\n') |
67 | | - print("Please follow the directions provided.") |
68 | | - input("\nPress enter to exit YAPO and take care of the above. >") |
69 | | - sys.exit() |
70 | | - |
71 | | - if os.path.isfile(os.path.join(src, "db.sqlite3")): |
72 | | - if not os.path.isfile(os.path.join(dest, "db.sqlite3")): |
73 | | - try: |
74 | | - shutil.move(src, dest) |
75 | | - okmoved = True |
76 | | - except: |
77 | | - print("Error moving the database") |
78 | | - print("There was an error moving the database to it's new location:") |
79 | | - print(f"{src} -> {dest}") |
80 | | - input("Please check the source and destination. Press enter to exit YAPO. >") |
81 | | - sys.exit() |
82 | | - else: |
83 | | - print("Databases at two locations") |
84 | | - print(f"There is a database file at both the below listed locations. You need to delete the one") |
85 | | - print("you don't wish to use and make sure the other is in the listed destination directory.") |
86 | | - print("This is a check because we have moved the database to a subdirectory.") |
87 | | - print("") |
88 | | - print(f"SOURCE: {src}") |
89 | | - print(f"DESTINATION: {src}") |
90 | | - input("Press enter to exit YAPO, and start it again when the above is taken care of. >") |
91 | | - sys.exit() |
92 | | - if okmoved: |
93 | | - print(f"The database was moved to {dest}.") |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | 44 | # Application definition |
99 | 45 |
|
100 | 46 | INSTALLED_APPS = [ |
|
191 | 137 | MEDIA_ROOT = Config().site_media_path |
192 | 138 | MEDIA_URL = f"/{Constants().site_media_subdir}/" |
193 | 139 |
|
| 140 | + |
| 141 | +IGNORABLE_404_URLS = [ |
| 142 | + re.compile(r'[^\\s]+(.*?)\\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF)$'), |
| 143 | +] |
| 144 | + |
| 145 | +LOGGING_CONFIG = None |
| 146 | +LOGGING = { |
| 147 | + 'version': 1, |
| 148 | + 'disable_existing_loggers': True, |
| 149 | + 'formatters': { |
| 150 | + }, |
| 151 | + 'filters': { |
| 152 | + 'require_debug_false': { |
| 153 | + '()': 'django.utils.log.RequireDebugFalse' |
| 154 | + } |
| 155 | + }, |
| 156 | + 'handlers': { |
| 157 | + 'null': { |
| 158 | + 'level': 'ERROR', |
| 159 | + 'class': 'django.utils.log.NullHandler', |
| 160 | + }, |
| 161 | + 'mail_admins': { |
| 162 | + 'level': 'ERROR', |
| 163 | + 'filters': ['require_debug_false'], |
| 164 | + 'class': 'django.utils.log.AdminEmailHandler', |
| 165 | + }, |
| 166 | + }, |
| 167 | + 'loggers': { |
| 168 | + 'django.request': { |
| 169 | + 'handlers': ['null', 'default'], |
| 170 | + 'level': 'ERROR', |
| 171 | + 'propagate': False, |
| 172 | + }, |
| 173 | +# 'requests': { |
| 174 | +# # The requests library is too verbose in it's logging, reducing the verbosity in our logs. |
| 175 | +# 'handlers': ['null', 'default'], |
| 176 | +# 'level': 'WARNING', |
| 177 | +# 'propagate': True, |
| 178 | +# }, |
| 179 | +# 'urllib3': { |
| 180 | +# 'handers': ['null', 'default'], |
| 181 | +# 'level': 'WARNING', |
| 182 | +# 'propagate': True |
| 183 | +# }, |
| 184 | + } |
| 185 | +} |
194 | 186 | # APPEND_SLASH = True |
195 | 187 |
|
196 | 188 | REST_FRAMEWORK = { |
|
0 commit comments