First commit
This commit is contained in:
commit
982b1e3afe
|
@ -0,0 +1 @@
|
|||
John Doe <john.doe@entrouvert.com>
|
|
@ -0,0 +1,2 @@
|
|||
Project Name is entirely under the copyright of Entr'ouvert and distributed
|
||||
under the license AGPLv3 or later.
|
|
@ -0,0 +1,9 @@
|
|||
recursive-include project_name/templates *.html
|
||||
recursive-include project_name/static *.gif *.png *.css *.ttf *.js
|
||||
recursive-include project_name/locale *.po *.mo
|
||||
recursive-include project_name/project_name/templates *.html
|
||||
recursive-include project_name/project_name/static *.gif *.png *.css *.ttf *.js
|
||||
recursive-include project_name/project_name/locale *.po *.mo
|
||||
include VERSION
|
||||
include AUTHORS.txt
|
||||
include COPYING
|
|
@ -0,0 +1,16 @@
|
|||
Project Name
|
||||
============
|
||||
|
||||
To start do:
|
||||
|
||||
./manage.py migrate
|
||||
./manage.py runserver
|
||||
|
||||
To use your own settings make the LOCAL_SETTINGS environment variable point to
|
||||
a settings file that will be executed in the context of the project settings
|
||||
module, at its end.
|
||||
|
||||
Settings
|
||||
========
|
||||
|
||||
FIXME
|
|
@ -0,0 +1,56 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "Give project name (it must match regexp ^[a-z][a-z0-9-]+$ )"
|
||||
read PROJECT_NAME
|
||||
|
||||
if ! echo $PROJECT_NAME | grep -q '^[a-z][a-z0-9-]\+$'; then
|
||||
echo "Invalid project name:" $PROJECT_NAME
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPPER_UNDERSCORED=`echo $PROJECT_NAME | tr a-z A-Z | sed 's/-/_/g'`
|
||||
LOWER_UNDERSCORED=`echo $PROJECT_NAME | sed 's/-/_/g'`
|
||||
TITLECASE=`echo $PROJECT_NAME | sed 's/-/ /g;s/.*/\L&/; s/[a-z]*/\u&/g'`
|
||||
|
||||
echo Project name: $PROJECT_NAME
|
||||
echo Uppercase underscored: $UPPER_UNDERSCORED
|
||||
echo Lowercase underscored: $LOWER_UNDERSCORED
|
||||
echo Titlecase: $TITLECASE
|
||||
|
||||
if [ -d .git ]; then
|
||||
MV='git mv'
|
||||
else
|
||||
git init
|
||||
MV=mv
|
||||
fi
|
||||
|
||||
sed -i \
|
||||
-e "s/project_name/$LOWER_UNDERSCORED/g" \
|
||||
-e "s/project-name/$PROJECT_NAME/g" \
|
||||
-e "s/PROJECT_NAME/A2_$UPPER_UNDERSCORED_/g" \
|
||||
-e "s/Project Name/$TITLECASE/g" \
|
||||
*.py */*.py */*/*.py README COPYING MANIFEST.in `find debian -type f`
|
||||
|
||||
for FILE in debian/*; do
|
||||
if [ -f $FILE ]; then
|
||||
NEWNAME=`echo $FILE | sed "s/project-name/$PROJECT_NAME/"`
|
||||
if [ "x$FILE" != "x$NEWNAME" ]; then
|
||||
$MV $FILE $NEWNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
$MV project_name/static/project_name \
|
||||
project_name/static/$LOWER_UNDERSCORED
|
||||
$MV project_name/project_name \
|
||||
project_name/$LOWER_UNDERSCORED
|
||||
$MV project_name/templates/project_name \
|
||||
project_name/templates/$LOWER_UNDERSCORED
|
||||
$MV project_name $LOWER_UNDERSCORED
|
||||
|
||||
git rm adapt.sh || true
|
||||
|
||||
git add .
|
||||
git commit -m "Initialize $PROJECT_NAME"
|
||||
git tag -a -m '0.1' v0.1
|
|
@ -0,0 +1,5 @@
|
|||
project-name (0.1-1) stable; urgency=low
|
||||
|
||||
* Initial release. (Closes: #XXXXXX)
|
||||
|
||||
-- EO Admin <admin@entrouvert.com> Wed, 11 Feb 2015 11:24:07 +0100
|
|
@ -0,0 +1 @@
|
|||
7
|
|
@ -0,0 +1,32 @@
|
|||
Source: project-name
|
||||
Maintainer: Entr'ouvert <info@entrouvert.com>
|
||||
Section: python
|
||||
Priority: optional
|
||||
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.7), debhelper (>= 7.4.3),
|
||||
python-django (>= 1.7)
|
||||
Standards-Version: 3.9.1
|
||||
XS-Python-Version: >= 2.7, << 3.0
|
||||
|
||||
Package: project-name
|
||||
Architecture: all
|
||||
Pre-Depends: python-django (>= 1.7), postgresql
|
||||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python (>= 2.7),
|
||||
python-project-name (= ${binary:Version}),
|
||||
python-psycopg2,
|
||||
gunicorn,
|
||||
dbconfig-common,
|
||||
debconf | debconf-2.0,
|
||||
ucf
|
||||
Recommends: postgresql-client, python-memcache,
|
||||
memcached, python-raven, python-entrouvert
|
||||
Suggests: nginx
|
||||
Description: Project Name
|
||||
|
||||
Package: python-project-name
|
||||
Architecture: all
|
||||
Pre-Depends: python-django (>= 1.7)
|
||||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python (>= 2.7), python-django-sekizai
|
||||
Description: Project Name Python files
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export DATABASE_ENGINE='django.db.backends.postgresql_psycopg2'
|
||||
export DATABASE_NAME='_DBC_DBNAME_'
|
||||
export DATABASE_USER='_DBC_DBUSER_'
|
||||
export DATABASE_PASSWORD='_DBC_DBPASS_'
|
||||
export DATABASE_HOST='localhost'
|
|
@ -0,0 +1,56 @@
|
|||
import os.path
|
||||
|
||||
# Debian defaults
|
||||
DEBUG = False
|
||||
|
||||
STATIC_ROOT = '/var/lib/project-name/collectstatic/'
|
||||
STATICFILES_DIRS = ['/var/lib/project-name/static',] + STATICFILES_DIRS
|
||||
TEMPLATE_DIRS = ['/var/lib/project-name/templates',] + TEMPLATE_DIRS
|
||||
LOCALE_PATHS = ['/var/lib/project-name/locale',] + LOCALE_PATHS
|
||||
MEDIA_ROOT = '/var/lib/project-name/media/'
|
||||
|
||||
ADMINS = (
|
||||
# send tracebacks to root
|
||||
('root', 'root@localhost'),
|
||||
)
|
||||
|
||||
if os.path.exists('/var/lib/project-name/secret_key'):
|
||||
SECRET_KEY = file('/var/lib/project-name/secret_key').read()
|
||||
|
||||
def read_database_configuration():
|
||||
'''Extract database configuration from environment variables'''
|
||||
for key in os.environ:
|
||||
if key.startswith('DATABASE_'):
|
||||
prefix, db_key = key.split('_', 1)
|
||||
DATABASES['default'][db_key] = os.environ[key]
|
||||
|
||||
read_database_configuration()
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'formatters': {
|
||||
'syslog': {
|
||||
'format': '%(levelname)s %(name)s.%(funcName)s: %(message)s',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'syslog': {
|
||||
'level': 'INFO',
|
||||
'address': '/dev/log',
|
||||
'class': 'logging.handlers.SysLogHandler',
|
||||
'formatter': 'syslog',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'project_name': {
|
||||
'level': 'INFO',
|
||||
'handlers': ['syslog', ],
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
CONFIG_FILE='/etc/project-name/settings.py'
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
execfile('/etc/project-name/settings.py')
|
|
@ -0,0 +1,12 @@
|
|||
access_log /var/log/nginx/project-name-access.log combined;
|
||||
error_log /var/log/nginx/project-name-error.log;
|
||||
|
||||
location /project-name/static {
|
||||
alias /var/lib/project-name/collectstatic;
|
||||
}
|
||||
|
||||
location /project-name {
|
||||
proxy_pass http://unix:/var/run/project-name/project-name.sock;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header SCRIPT_NAME /project-name
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$(whoami)" != "project-name" ]; then
|
||||
if which sudo >/dev/null; then
|
||||
if sudo -v -u project-name; then
|
||||
sudo -u project-name project-name-ctl "$@"
|
||||
exit $?
|
||||
fi
|
||||
echo "You must run this script with project-name user"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
export LOCAL_SETTINGS='/usr/share/project-name/debian_config.py'
|
||||
|
||||
if [ -f /etc/project-name/db.conf ]; then
|
||||
. /etc/project-name/db.conf
|
||||
fi
|
||||
|
||||
/usr/share/python-project-name/manage.py "$@"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
# config maintainer script for foo-pgsql
|
||||
|
||||
set -e
|
||||
|
||||
# source debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
# source dbconfig-common shell library, and call the hook function
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
|
||||
. /usr/share/dbconfig-common/dpkg/config.pgsql
|
||||
dbc_go project-name $@
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
/usr/bin/project-name-ctl clearsessions
|
|
@ -0,0 +1,9 @@
|
|||
/usr/share/project-name
|
||||
/var/lib/project-name/static
|
||||
/var/lib/project-name/collectstatic
|
||||
/var/lib/project-name/media
|
||||
/var/lib/project-name/templates
|
||||
/var/lib/project-name/locale
|
||||
/var/run/project-name
|
||||
/var/log/project-name
|
||||
/etc/project-name
|
|
@ -0,0 +1,209 @@
|
|||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: project-name
|
||||
# Required-Start: $network $local_fs
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Project Name is a versatile identity provider
|
||||
# Description: Project Name is a versatile identity provider
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Jérôme Schneider <jschneider@entrouvert.com>
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC=project-name
|
||||
NAME=project-name
|
||||
DAEMON=/usr/bin/gunicorn
|
||||
PID_DIR=/var/run/$NAME
|
||||
CACHE_DIR=/var/cache/$NAME
|
||||
LOG_DIR=/var/log/$NAME
|
||||
PIDFILE=$PID_DIR/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
CTL=/usr/bin/$NAME-ctl
|
||||
SOCKFILE=$PID_DIR/$NAME.sock
|
||||
BIND=unix:$SOCKFILE
|
||||
DJANGO_CONFIG_FILE=/usr/share/$NAME/debian_config.py
|
||||
|
||||
USER=project-name
|
||||
GROUP=project-name
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x $DAEMON ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
DAEMON_ARGS="--pid $PIDFILE \
|
||||
--user $USER --group $GROUP \
|
||||
--daemon \
|
||||
--access-logfile $LOG_DIR/gunicorn-access.log \
|
||||
--log-file $LOG_DIR/gunicorn-error.log \
|
||||
--bind=$BIND \
|
||||
--workers=10 \
|
||||
--worker-class=sync \
|
||||
--timeout=60 \
|
||||
project_name.wsgi:application"
|
||||
|
||||
# Load config
|
||||
if [ -f /etc/project-name/db.conf ]; then
|
||||
. /etc/project-name/db.conf
|
||||
fi
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# Create pid directory
|
||||
if [ ! -d $PID_DIR ]; then
|
||||
install -d -m 755 -o $USER -g $GROUP $PID_DIR
|
||||
fi
|
||||
|
||||
# Create cache directory
|
||||
if [ ! -d $CACHE_DIR ]; then
|
||||
install -d -m 755 -o $USER -g $GROUP $CACHE_DIR
|
||||
fi
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
export DJANGO_CONFIG_FILE
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||||
|| return 1
|
||||
start-stop-daemon --start --quiet --exec $DAEMON -- \
|
||||
$DAEMON_ARGS \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been stopped
|
||||
# 1 if daemon was already stopped
|
||||
# 2 if daemon could not be stopped
|
||||
# other if a failure occurred
|
||||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
|
||||
RETVAL="$?"
|
||||
[ "$RETVAL" = 2 ] && return 2
|
||||
# Wait for children to finish too if this is a daemon that forks
|
||||
# and if the daemon is only ever run from this initscript.
|
||||
# If the above conditions are not satisfied then add some other code
|
||||
# that waits for the process to drop all resources that could be
|
||||
# needed by services started subsequently. A last resort is to
|
||||
# sleep for some time.
|
||||
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
|
||||
[ "$?" = 2 ] && return 2
|
||||
# Many daemons don't delete their pidfiles when they exit.
|
||||
rm -f $PIDFILE $SOCKFILE
|
||||
return "$RETVAL"
|
||||
}
|
||||
|
||||
#
|
||||
# Function that sends a SIGHUP to the daemon/service
|
||||
#
|
||||
do_reload() {
|
||||
#
|
||||
# If the daemon can reload its configuration without
|
||||
# restarting (for example, when it is sent a SIGHUP),
|
||||
# then implement that here.
|
||||
#
|
||||
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name `basename $DAEMON`
|
||||
return 0
|
||||
}
|
||||
|
||||
do_migrate() {
|
||||
log_action_msg "Applying new migrations .."
|
||||
su $USER -p -c "$CTL migrate"
|
||||
log_action_msg ".. done"
|
||||
}
|
||||
|
||||
do_collectstatic() {
|
||||
log_action_msg "Collecting static files .."
|
||||
su $USER -p -c "$CTL collectstatic --noinput"
|
||||
log_action_msg ".. done"
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting $DESC " "$NAME"
|
||||
do_migrate
|
||||
do_collectstatic
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) log_end_msg 0 ;;
|
||||
2) log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) log_end_msg 0 ;;
|
||||
2) log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
reload|force-reload)
|
||||
#
|
||||
# If do_reload() is not implemented then leave this commented out
|
||||
# and leave 'force-reload' as an alias for 'restart'.
|
||||
#
|
||||
log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
do_reload
|
||||
log_end_msg $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
#
|
||||
# If the "reload" option is implemented then remove the
|
||||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_migrate
|
||||
do_collectstatic
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
collectstatic)
|
||||
do_collectstatic
|
||||
;;
|
||||
migrate)
|
||||
do_migrate
|
||||
;;
|
||||
manage)
|
||||
shift
|
||||
$CTL "$@"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
debian/debian_config.py /usr/share/project-name/
|
||||
debian/project-name-ctl /usr/bin
|
||||
debian/db.conf.template /usr/share/project-name/
|
||||
debian/nginx.conf /usr/share/project-name/
|
|
@ -0,0 +1,76 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Postinst script for project-name
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
NAME=project-name
|
||||
PROJECT_NAME_USER=project-name
|
||||
PROJECT_NAME_GROUP=project-name
|
||||
PROJECT_NAME_HOME=/var/lib/project-name
|
||||
PROJECT_NAME_SECRET_KEY="$PROJECT_NAME_HOME/secret_key"
|
||||
|
||||
# source debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
if ! getent group $PROJECT_NAME_GROUP > /dev/null 2>&1; then
|
||||
echo -n "Adding group $PROJECT_NAME_GROUP.." >&2
|
||||
addgroup --quiet --system $PROJECT_NAME_GROUP
|
||||
echo "..done" >&2
|
||||
fi
|
||||
if ! getent passwd $PROJECT_NAME_USER > /dev/null 2>&1; then
|
||||
echo -n "Adding user $PROJECT_NAME_USER.." >&2
|
||||
adduser --quiet --system --gecos "Project Name daemon" \
|
||||
--ingroup $PROJECT_NAME_GROUP \
|
||||
--no-create-home --home $PROJECT_NAME_HOME \
|
||||
$PROJECT_NAME_USER
|
||||
echo "..done" >&2
|
||||
fi
|
||||
|
||||
if [ ! -f $PROJECT_NAME_SECRET_KEY ]; then
|
||||
echo -n "Generating a secret key.." >&2
|
||||
echo -n "`</dev/urandom tr -dc [:alnum:]-_\!\%\^:\; | head -c70`" > "$PROJECT_NAME_SECRET_KEY"
|
||||
chmod 0600 $PROJECT_NAME_SECRET_KEY
|
||||
chown $PROJECT_NAME_USER $PROJECT_NAME_SECRET_KEY
|
||||
echo "..done" >&2
|
||||
fi
|
||||
|
||||
|
||||
chown -R $PROJECT_NAME_USER:$PROJECT_NAME_GROUP \
|
||||
/var/lib/project-name/collectstatic \
|
||||
/var/lib/project-name/media \
|
||||
/var/run/project-name
|
||||
|
||||
# source dbconfig-common shell library, and call the hook function
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
|
||||
. /usr/share/dbconfig-common/dpkg/postinst.pgsql
|
||||
dbc_generate_include="template:/etc/project-name/db.conf"
|
||||
dbc_generate_include_args="-o template_infile=/usr/share/project-name/db.conf.template -U"
|
||||
dbc_generate_include_owner="root:project-name"
|
||||
dbc_generate_include_perms="640"
|
||||
dbc_pgsql_createdb_encoding="UTF8"
|
||||
dbc_go project-name $@
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
reconfigure|abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
db_stop
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
# postrm script for project-name
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in purge)
|
||||
deluser --quiet --system project-name > /dev/null || true
|
||||
rm -f /var/lib/project-name/secret_key
|
||||
rm -rf /var/lib/project-name/collectstatic/*
|
||||
# source debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
# source dbconfig-common shell library, and call the hook function
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
|
||||
. /usr/share/dbconfig-common/dpkg/postrm.pgsql
|
||||
dbc_go project-name $@
|
||||
fi
|
||||
|
||||
DBCONF=/etc/project-name/db.conf
|
||||
if [ "$1" = "purge" ]; then
|
||||
rm -f $DBCONF
|
||||
if which ucf >/dev/null 2>&1; then
|
||||
ucf --purge $DBCONF
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,2 @@
|
|||
/usr/share/python-project-name/
|
||||
/usr/share/python-project-name/themes/
|
|
@ -0,0 +1,2 @@
|
|||
AUTHORS.txt
|
||||
COPYING
|
|
@ -0,0 +1 @@
|
|||
usr/lib
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
project_name=$(CURDIR)/debian/project-name
|
||||
python_project_name=$(CURDIR)/debian/python-project-name
|
||||
|
||||
|
||||
%:
|
||||
dh $@ --with python2
|
||||
|
||||
override_dh_install:
|
||||
dh_install
|
||||
mv $(CURDIR)/debian/tmp/usr/bin/manage.py $(python_project_name)/usr/share/python-project-name/manage.py
|
||||
|
|
@ -0,0 +1 @@
|
|||
3.0 (quilt)
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
|
@ -0,0 +1 @@
|
|||
__version__ = "0.1"
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,16 @@
|
|||
import sys
|
||||
|
||||
class AppSettings(object):
|
||||
__PREFIX = 'PROJECT_NAME_'
|
||||
__DEFAULTS = {
|
||||
}
|
||||
|
||||
def __getattr__(self, name):
|
||||
from django.conf import settings
|
||||
if name not in self.__DEFAULTS:
|
||||
raise AttributeError
|
||||
return getattr(settings, self.__prefix + name, self.__DEFAULTS[name])
|
||||
|
||||
app_settings = AppSettings()
|
||||
app_settings.__name__ = __name__
|
||||
sys.modules[__name__] = app_settings
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,6 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def home(request):
|
||||
return render(request, 'project_name/home.html')
|
|
@ -0,0 +1,100 @@
|
|||
"""
|
||||
Django settings for project-name project.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.7/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.7/ref/settings/
|
||||
"""
|
||||
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '74lgky$@g*rv=@1o55b-^ct&)))+xf+r3*vqmy#bg6!89*-*ym'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
TEMPLATE_DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'sekizai',
|
||||
'project_name.project_name',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'project_name.urls'
|
||||
|
||||
WSGI_APPLICATION = 'project_name.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'project_name.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'project_name', 'static')]
|
||||
|
||||
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'project_name', 'templates')]
|
||||
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
LOCALE_PATHS = [os.path.join(BASE_DIR, 'project_name', 'locale')]
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS += ('sekizai.context_processors.sekizai',)
|
||||
|
||||
ATOMIC = True
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.7/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
if 'LOCAL_SETTINGS' in os.environ:
|
||||
execfile(os.environ['LOCAL_SETTINGS'])
|
|
@ -0,0 +1,17 @@
|
|||
{% load i18n sekizai_tags staticfiles %}<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Project Name</title>
|
||||
<link rel="stylesheet" href="{% static "project_name/css/style.css" %}" />
|
||||
{% render_block "css" %}
|
||||
{% render_block "js" %}
|
||||
</head>
|
||||
|
||||
<body {% block bodyattr %}{% endblock %}>
|
||||
<div id="content">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% render_block "js-endpage" %}
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
Salut tout le monde!
|
||||
{% endblock %}
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,9 @@
|
|||
from django.conf.urls import patterns, include, url
|
||||
from django.contrib import admin
|
||||
|
||||
from .project_name.views import home
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', home, name='home'),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
)
|
|
@ -0,0 +1,14 @@
|
|||
"""
|
||||
WSGI config for project-name project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings")
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
application = get_wsgi_application()
|
|
@ -0,0 +1,119 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
''' Setup script for project-name
|
||||
'''
|
||||
|
||||
import os
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools.command.install_lib import install_lib as _install_lib
|
||||
from distutils.command.build import build as _build
|
||||
from distutils.command.sdist import sdist as _sdist
|
||||
from distutils.cmd import Command
|
||||
|
||||
class compile_translations(Command):
|
||||
description = 'compile message catalogs to MO files via django compilemessages'
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
from django.core.management import call_command
|
||||
for path in ['project_name']:
|
||||
if path.endswith('.py'):
|
||||
continue
|
||||
curdir = os.getcwd()
|
||||
os.chdir(os.path.realpath(path))
|
||||
call_command('compilemessages')
|
||||
os.chdir(curdir)
|
||||
|
||||
class build(_build):
|
||||
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
||||
|
||||
class sdist(_sdist):
|
||||
sub_commands = [('compile_translations', None)] + _sdist.sub_commands
|
||||
|
||||
class install_lib(_install_lib):
|
||||
def run(self):
|
||||
self.run_command('compile_translations')
|
||||
_install_lib.run(self)
|
||||
|
||||
def get_version():
|
||||
import glob
|
||||
import re
|
||||
import os
|
||||
|
||||
version = None
|
||||
for d in glob.glob('*'):
|
||||
if not os.path.isdir(d):
|
||||
continue
|
||||
module_file = os.path.join(d, '__init__.py')
|
||||
if not os.path.exists(module_file):
|
||||
continue
|
||||
for v in re.findall("""__version__ *= *['"](.*)['"]""",
|
||||
open(module_file).read()):
|
||||
assert version is None
|
||||
version = v
|
||||
if version:
|
||||
break
|
||||
assert version is not None
|
||||
if os.path.exists('.git'):
|
||||
import subprocess
|
||||
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
||||
stdout=subprocess.PIPE)
|
||||
result = p.communicate()[0]
|
||||
assert p.returncode == 0, 'git returned non-zero'
|
||||
new_version = result.split()[0][1:]
|
||||
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
|
||||
version = new_version.replace('-', '.')
|
||||
return version
|
||||
|
||||
|
||||
setup(name="project-name",
|
||||
version=get_version(),
|
||||
license="AGPLv3 or later",
|
||||
description="",
|
||||
long_description=file('README').read(),
|
||||
url="http://dev.entrouvert.org/projects/project-name/",
|
||||
author="Entr'ouvert",
|
||||
author_email="info@entrouvert.org",
|
||||
scripts=['manage.py',],
|
||||
include_package_data=True,
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
],
|
||||
setup_requires=[
|
||||
'django>=1.7',
|
||||
],
|
||||
tests_require=[
|
||||
'nose>=0.11.4',
|
||||
],
|
||||
package_data={
|
||||
'': [
|
||||
'locale/*/*/*.po',
|
||||
'locale/*/*/*.mo',
|
||||
'templates/*.html',
|
||||
'templates/*/*.html',
|
||||
'templates/*/*/*.html',
|
||||
'static/*/*/*.css',
|
||||
'static/*/*.css',
|
||||
'static/*/*/*.png',
|
||||
'static/*/*.png',
|
||||
'static/*/*/*.gif',
|
||||
'static/*/*.gif',
|
||||
'static/*/*/*.js',
|
||||
'static/*/*.js',
|
||||
'static/*/*/*.ttf',
|
||||
'static/*/*.ttf',
|
||||
],
|
||||
},
|
||||
cmdclass={
|
||||
'build': build,
|
||||
'install_lib': install_lib,
|
||||
'compile_translations': compile_translations,
|
||||
'sdist': sdist,
|
||||
},
|
||||
)
|
Reference in New Issue