Initial commit.
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
|
||||
##
|
||||
## Additional settings for django-alte-maschinen
|
||||
##
|
||||
|
||||
BASE_VAR_DIR = os.path.join(BASE_DIR, 'var')
|
||||
BASE_SHARE_DIR = os.path.join(BASE_DIR, 'common')
|
||||
|
||||
INSTALLED_APPS += [
|
||||
'bootstrap3',
|
||||
'datetimewidget',
|
||||
'django_extensions',
|
||||
# Our main app
|
||||
'dav_events',
|
||||
]
|
||||
|
||||
DATABASES['default'] = {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_VAR_DIR, 'db', 'devel.sqlite3'),
|
||||
}
|
||||
|
||||
STATIC_ROOT = os.path.join(BASE_VAR_DIR, 'www', 'static')
|
||||
|
||||
LANGUAGE_CODE = 'de'
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'default': {
|
||||
'format': '%(asctime)s - %(name)s - %(levelname)s: %(message)s'
|
||||
},
|
||||
'verbose': {
|
||||
'format': '%(asctime)s -- %(processName)s[%(process)d]:%(threadName)s[%(thread)d] -- %(name)s -- %(module)s...%(funcName)s() -- %(pathname)s:%(lineno)d -- %(levelname)s: %(message)s'
|
||||
},
|
||||
},
|
||||
'filters': {
|
||||
'require_debug_true': {
|
||||
'()': 'django.utils.log.RequireDebugTrue',
|
||||
},
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'filters': ['require_debug_true'],
|
||||
'class': 'logging.StreamHandler',
|
||||
},
|
||||
'null': {
|
||||
'class': 'logging.NullHandler',
|
||||
},
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
},
|
||||
'default_log': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'default.log'),
|
||||
'formatter': 'default',
|
||||
},
|
||||
'error_log': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'error.log'),
|
||||
'formatter': 'default',
|
||||
},
|
||||
'debug_log': {
|
||||
'level': 'DEBUG',
|
||||
'filters': ['require_debug_true'],
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'debug.log'),
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'django_log': {
|
||||
'level': 'INFO',
|
||||
'filters': ['require_debug_true'],
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'django.log'),
|
||||
'formatter': 'default',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'level': 'INFO',
|
||||
'handlers': ['console', 'django_log'],
|
||||
'propagate': False,
|
||||
},
|
||||
'django.request': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['mail_admins'],
|
||||
'propagate': True,
|
||||
},
|
||||
'django.security': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['mail_admins'],
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', 'default_log', 'error_log', 'debug_log'],
|
||||
},
|
||||
}
|
||||
7
dav_events/console_scripts/Resources/django.main.urls.py
Normal file
7
dav_events/console_scripts/Resources/django.main.urls.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^', include('dav_events.urls', namespace='dav_events')),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
0
dav_events/console_scripts/__init__.py
Normal file
0
dav_events/console_scripts/__init__.py
Normal file
98
dav_events/console_scripts/admin.py
Normal file
98
dav_events/console_scripts/admin.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import argparse
|
||||
import os
|
||||
import pkg_resources
|
||||
import posix
|
||||
import sys
|
||||
|
||||
VERSION = '0.1'
|
||||
|
||||
|
||||
class AdminCommand(object):
|
||||
def _setup_argparser(self):
|
||||
kwargs = {
|
||||
'description': 'Tool to manage the DAV Events django project installation.',
|
||||
'epilog': 'Off Belay.',
|
||||
}
|
||||
parser = argparse.ArgumentParser(**kwargs)
|
||||
|
||||
parser.add_argument('-V', '--version', action='version',
|
||||
version='%(prog)s ' + VERSION)
|
||||
|
||||
subparsers = parser.add_subparsers(dest='subcmd', metavar='CMD',
|
||||
title='subcommands',
|
||||
description="Use '%(prog)s CMD -h' to show help for a subcommand")
|
||||
subparser = subparsers.add_parser('setup', help='Setup the installation.')
|
||||
subparser.add_argument('path', metavar='PATH',
|
||||
help='A directory, where the project files will be installed.')
|
||||
|
||||
return parser
|
||||
|
||||
def _parse_args(self, argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
if not argv:
|
||||
argv = ['--help']
|
||||
|
||||
return self._argparser.parse_args(argv)
|
||||
|
||||
def _subcmd_setup(self, cmd_args):
|
||||
django_project_name = 'main'
|
||||
django_project_path = cmd_args.path
|
||||
|
||||
sys.stdout.write('Setup installation in \'{path}\'...\n'.format(path=django_project_path))
|
||||
|
||||
if os.path.exists(django_project_path):
|
||||
if not os.path.isdir(django_project_path):
|
||||
sys.stderr.write('{path}: Not a directory.\n'.format(path=django_project_path))
|
||||
return posix.EX_USAGE
|
||||
else:
|
||||
os.makedirs(django_project_path)
|
||||
|
||||
sys.stdout.write('Creating django project...\n')
|
||||
django_cmd = 'django-admin startproject {name} "{path}"'.format(name=django_project_name,
|
||||
path=django_project_path)
|
||||
exitval = os.system(django_cmd)
|
||||
if exitval != posix.EX_OK:
|
||||
return exitval
|
||||
|
||||
sys.stdout.write('Creating directories...\n')
|
||||
dirs = [
|
||||
os.path.join(django_project_path, 'var', 'db'),
|
||||
os.path.join(django_project_path, 'var', 'log'),
|
||||
os.path.join(django_project_path, 'var', 'www', 'static'),
|
||||
]
|
||||
|
||||
for d in dirs:
|
||||
sys.stdout.write(' - %s\n' % d)
|
||||
os.makedirs(d)
|
||||
|
||||
sys.stdout.write('Configure django project...\n')
|
||||
|
||||
input_file = os.path.join('Resources', 'django.main.additional_settings.py')
|
||||
output_file = os.path.join(django_project_path, django_project_name, 'settings.py')
|
||||
with open(output_file, 'a') as f:
|
||||
f.write(pkg_resources.resource_string(__package__, input_file))
|
||||
|
||||
input_file = os.path.join('Resources', 'django.main.urls.py')
|
||||
output_file = os.path.join(django_project_path, django_project_name, 'urls.py')
|
||||
with open(output_file, 'w') as f:
|
||||
f.write(pkg_resources.resource_string(__package__, input_file))
|
||||
|
||||
return posix.EX_OK
|
||||
|
||||
def __init__(self):
|
||||
self._argparser = self._setup_argparser()
|
||||
|
||||
def __call__(self, argv=None):
|
||||
cmd_args = self._parse_args(argv)
|
||||
subcmd = cmd_args.subcmd
|
||||
method_name = '_subcmd_{}'.format(subcmd)
|
||||
method = getattr(self, method_name)
|
||||
exitval = method(cmd_args)
|
||||
return exitval
|
||||
|
||||
|
||||
def main():
|
||||
cmd = AdminCommand()
|
||||
exitval = cmd()
|
||||
sys.exit(exitval)
|
||||
Reference in New Issue
Block a user