From 82cdb46860033738cff0ebc77ea6af75fd66fbb5 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Thu, 10 Nov 2011 05:55:19 +0000 Subject: move settings.py for portal gui django app to ${sysconfdir}/rpki since it really is a configuration file svn path=/branches/tk103/; revision=4078 --- buildtools/make-django-script.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 buildtools/make-django-script.py (limited to 'buildtools/make-django-script.py') diff --git a/buildtools/make-django-script.py b/buildtools/make-django-script.py new file mode 100644 index 00000000..67dd8ed3 --- /dev/null +++ b/buildtools/make-django-script.py @@ -0,0 +1,37 @@ +""" +Convert a Python script into an executable Python script. Mostly this +means constructing a header based on a few parameters supplied by +autoconf. + +$Id$ + +Copyright (C) 2011 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +import os, sys + +sys.stdout.write('''\ +#!%(AC_PYTHON_INTERPRETER)s +# Automatically constructed script header + +import sys, os +sys.path.append('%(AC_PYTHONPATH)s') +os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' + +# Original script starts here + +''' % os.environ) + +sys.stdout.write(sys.stdin.read()) -- cgit v1.2.3 From 77c7261f1f8173f8dcb0e30769fb553ac8bfb30c Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Fri, 11 Nov 2011 01:20:44 +0000 Subject: prepend ${sysconfdir}/rpki to sys.path to avoid picking up the wrong settings.py by accident svn path=/branches/tk103/; revision=4082 --- buildtools/make-django-script.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'buildtools/make-django-script.py') diff --git a/buildtools/make-django-script.py b/buildtools/make-django-script.py index 67dd8ed3..c8b3ef68 100644 --- a/buildtools/make-django-script.py +++ b/buildtools/make-django-script.py @@ -1,7 +1,5 @@ """ -Convert a Python script into an executable Python script. Mostly this -means constructing a header based on a few parameters supplied by -autoconf. +Prepend boilerplate required for scripts which make use of Django's ORM. $Id$ @@ -27,7 +25,9 @@ sys.stdout.write('''\ # Automatically constructed script header import sys, os -sys.path.append('%(AC_PYTHONPATH)s') +# sys.path[0] is the cwd of the script being executed, so we add the +# path to the settings.py file after it +sys.path.insert(1, '%(AC_PYTHONPATH)s') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # Original script starts here -- cgit v1.2.3