mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Fixed docker image. Fixed issue with environment variable interpolation (on Linux, it is case sensitive, so converting to lowercase was bad. Cleaned up directory structure.
This commit is contained in:
@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
|
||||
|
||||
import os
|
||||
import logging
|
||||
from os.path import dirname as up
|
||||
|
||||
#
|
||||
# Basic Django stuff
|
||||
@ -119,9 +120,11 @@ LOG_FORMAT = '%(asctime)s|%(process)d|%(thread)d|%(name)s|%(filename)s|%(lineno)
|
||||
#
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
CONFIG_DIR = os.path.join(BASE_DIR, "config")
|
||||
DATA_DIR = os.path.join(BASE_DIR, "data")
|
||||
PROJECT_ROOT = up(up(os.path.dirname(__file__))) # Project root
|
||||
BASE_DIR = os.path.join(PROJECT_ROOT, "app") # Base dir of the application
|
||||
CONFIG_DIR = os.path.join(PROJECT_ROOT, "config")
|
||||
DATA_DIR = os.path.join(PROJECT_ROOT, "data")
|
||||
STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
|
||||
|
||||
_DEFAULT_CONFIG_FILE = os.path.join(CONFIG_DIR, 'config.ini')
|
||||
_DEFAULT_LOG_FILE = os.path.join(DATA_DIR, 'log.log')
|
||||
@ -160,7 +163,14 @@ def load_config_ini():
|
||||
import dj_database_url
|
||||
|
||||
cfg = ConfigParser(allow_no_value=True, interpolation=ExtendedInterpolatorWithEnv())
|
||||
cfg.read([DEFAULTS_FILE, CONFIG_FILE])
|
||||
read_ok = cfg.read([DEFAULTS_FILE, CONFIG_FILE])
|
||||
|
||||
if DEFAULTS_FILE not in read_ok:
|
||||
print('Failed to read file ' + DEFAULTS_FILE)
|
||||
raise Exception('Cannot read file ' + DEFAULTS_FILE)
|
||||
if CONFIG_FILE not in read_ok:
|
||||
print('Failed to read file ' + CONFIG_FILE)
|
||||
raise Exception('Cannot read file ' + CONFIG_FILE)
|
||||
|
||||
# Debug
|
||||
global DEBUG
|
||||
@ -183,7 +193,7 @@ def load_config_ini():
|
||||
}
|
||||
|
||||
if cfg.has_option('global', 'DatabaseURL'):
|
||||
DATABASES['default'] = dj_database_url.parse(cfg.get('global', 'DatabaseURL'))
|
||||
DATABASES['default'] = dj_database_url.parse(cfg.get('global', 'DatabaseURL'), conn_max_age=600)
|
||||
|
||||
else:
|
||||
DATABASES['default'] = {
|
||||
|
@ -35,7 +35,7 @@ class ExtendedInterpolatorWithEnv(Interpolation):
|
||||
def _resolve_section_option(self, section, option, parser):
|
||||
if section == 'env':
|
||||
return os.getenv(option, '')
|
||||
return parser.get(section, option, raw=True)
|
||||
return parser.get(section, parser.optionxform(option), raw=True)
|
||||
|
||||
def _interpolate_some(self, parser, option, accum, rest, section, map,
|
||||
depth):
|
||||
@ -70,7 +70,7 @@ class ExtendedInterpolatorWithEnv(Interpolation):
|
||||
v = self._resolve_option(opt, map)
|
||||
elif len(path) == 2:
|
||||
sect = path[0]
|
||||
opt = parser.optionxform(path[1])
|
||||
opt = path[1]
|
||||
v = self._resolve_section_option(sect, opt, parser)
|
||||
else:
|
||||
raise InterpolationSyntaxError(
|
||||
|
@ -1 +0,0 @@
|
||||
config
|
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#./manage.py runserver 0.0.0.0:8000 --noreload
|
||||
./manage.py migrate
|
||||
gunicorn -b 0.0.0.0:8000 -w 4 YtManager.wsgi
|
@ -1,11 +0,0 @@
|
||||
apscheduler
|
||||
gunicorn
|
||||
django
|
||||
django-crispy-forms
|
||||
dj_database_url
|
||||
youtube-dl
|
||||
google-api-python-client
|
||||
google_auth_oauthlib
|
||||
oauth2client
|
||||
psycopg2-binary
|
||||
python-dateutil
|
Reference in New Issue
Block a user