From a6f61af513a5101d056bafb1e21106a722dfc4eb Mon Sep 17 00:00:00 2001 From: Maxime Petazzoni Date: Mon, 7 May 2012 19:13:25 -0700 Subject: [PATCH] Rework configuration templates Use the more traditional '.dist' extension for configuration templates that are part of the MapOSMatic distribution. Update the installation instructions accordingly. Includes some style fixes in the INSTALL and template files, as well as a fix to the wrapper script to correctly allow for an undefined log location (defaults to stderr). Signed-off-by: Maxime Petazzoni --- INSTALL | 25 +++++---- scripts/config.py-template | 27 ---------- scripts/config.py.dist | 25 +++++++++ scripts/wrapper.py | 2 +- ...tic.wsgi-template => maposmatic.wsgi.dist} | 0 ...cal.py-template => settings_local.py.dist} | 51 ++++++++++++------- 6 files changed, 72 insertions(+), 58 deletions(-) delete mode 100755 scripts/config.py-template create mode 100755 scripts/config.py.dist rename www/{maposmatic.wsgi-template => maposmatic.wsgi.dist} (100%) rename www/{settings_local.py-template => settings_local.py.dist} (78%) diff --git a/INSTALL b/INSTALL index b1bafc98..a1759a0b 100644 --- a/INSTALL +++ b/INSTALL @@ -6,16 +6,20 @@ Dependencies MapOSMatic depends on : - * Python, the programming language + * Python, the programming language. * Django, the Web framework used to develop the Web front-end, but also used for the maposmaticd daemon to conveniently access the - database through Django's ORM + database through Django's ORM. - * python-psycopg2, to let Django access the PostgreSQL database + * OCitySMap, the rendering pipeline for MapOSMatic. See OCitySMap's + install file for installation instructions and OCitySMap's + dependencies. + + * python-psycopg2, to let Django access the PostgreSQL database. * python-feedparser, to parse the MapOSMatic blog feed and display - the latest entries on the main MapOSMatic website + the latest entries on the main MapOSMatic website. * python-imaging, to render PNG maps. @@ -23,13 +27,12 @@ MapOSMatic depends on : * JSON (any python-*json package should work). - * ImageMagick, for rendering the thumbnails of multi-page maps + * ImageMagick, for rendering the thumbnails of multi-page maps. On an debian/ubuntu installation, the following should be enough: sudo aptitude install python-django python-psycopg2 \ - python-feedparser python-imaging gettext \ - imagemagick + python-feedparser python-imaging gettext imagemagick You will also most likely need a working PostGIS installation for the entire pipeline to run. See the INSTALL documentation of OcitySMap for @@ -39,11 +42,11 @@ Setup ----- The www/ directory contains the Django web application. The file -www/settings_local.py-template must be copied to www/settings_local.py -and modified to match your installation configuration. +www/settings_local.py.dist must be copied to www/settings_local.py and +modified to match your installation configuration. -Likewise for www/maposmatic.wsgi-template and -scripts/config.py-template. +Likewise for www/maposmatic.wsgi.dist and scripts/config.py.dist, +respectively as www/maposmatic.wsgi and scripts/config.py. The database must then be initialized with the tables needed for MapOSMatic, using : diff --git a/scripts/config.py-template b/scripts/config.py-template deleted file mode 100755 index 23a51f94..00000000 --- a/scripts/config.py-template +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copy this file as 'config.py' and edit the following lines to match your -# installation. - -# Path to your OCitySMap installation -OCITYSMAP_PATH = '/path/to/ocitysmap' - -# Log file for MapOSMatic. Leave empty for stderr. -MAPOSMATIC_LOG = '/tmp/maposmaticd.log' - -# Log level (lower is more verbose) -# 50: critical -# 40: error -# 30: warning -# 20: info -# 10: debug -# 0: not set (discouraged) -MAPOSMATIC_LVL = 20 - -### -## Optional: if you need to extend the python search path, then write -## something like the following: -# import os -# os.environ['PYTHONPATH'] = '%s:%s' % ('/path/to/lib/python/site-packages', -# os.environ.get('PYTHONPATH', '')) diff --git a/scripts/config.py.dist b/scripts/config.py.dist new file mode 100755 index 00000000..f175245f --- /dev/null +++ b/scripts/config.py.dist @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# coding: utf-8 + +import os + +# Optional: if you need to extend the Python search path, then write +# something like the following: +# os.environ['PYTHONPATH'] = ('%s:%s' % +# ('/path/to/lib/python/site-packages', +# os.environ.get('PYTHONPATH', ''))) + +# Path to your OCitySMap installation +OCITYSMAP_PATH = '/path/to/ocitysmap' + +# Log file for MapOSMatic. Leave empty for stderr. +MAPOSMATIC_LOG = None + +# Log level (lower is more verbose) +# 50: critical +# 40: error +# 30: warning +# 20: info +# 10: debug +# 0: not set (discouraged) +MAPOSMATIC_LVL = 20 diff --git a/scripts/wrapper.py b/scripts/wrapper.py index 7fc16803..a027edcf 100755 --- a/scripts/wrapper.py +++ b/scripts/wrapper.py @@ -34,7 +34,7 @@ if __name__ == '__main__': os.environ['PYTHONPATH'] = '%s:%s:%s' % (OCITYSMAP_PATH, root, os.environ.get('PYTHONPATH', '')) os.environ['DJANGO_SETTINGS_MODULE'] = 'www.settings' - os.environ['MAPOSMATIC_LOG_FILE'] = MAPOSMATIC_LOG + os.environ['MAPOSMATIC_LOG_FILE'] = MAPOSMATIC_LOG or '' os.environ['MAPOSMATIC_LOG_LEVEL'] = str(MAPOSMATIC_LVL) os.execv(os.path.join(root, sys.argv[1]), sys.argv[1:]) diff --git a/www/maposmatic.wsgi-template b/www/maposmatic.wsgi.dist similarity index 100% rename from www/maposmatic.wsgi-template rename to www/maposmatic.wsgi.dist diff --git a/www/settings_local.py-template b/www/settings_local.py.dist similarity index 78% rename from www/settings_local.py-template rename to www/settings_local.py.dist index 306831f2..c9cf0473 100644 --- a/www/settings_local.py-template +++ b/www/settings_local.py.dist @@ -22,8 +22,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - import logging +import os +import sys + +# Optional: if you need to extend the Python search path, for example to +# include your OCitySMap installation, then write something like the following: +# sys.path.append('/path/to/ocitysmap') +# sys.path.append('/path/to/lib/python/site-packages') DEBUG = True @@ -32,17 +38,31 @@ ADMINS = ( ) DATABASES = { + # For SQLite: 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'maposmatic', - 'USER': 'maposmatic', - 'PASSWORD': 'ereiamjh', - 'HOST': 'localhost', + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(os.path.dirname(__file__), + 'datastore.sqlite3'), + 'USER': '', + 'PASSWORD': '', + 'HOST': '', 'PORT': '' - } - } + }, -# Path to ocitysmap's config file to use, or None for the default in ~/ + # For PostgreSQL: + #'default': { + # 'ENGINE': 'django.db.backends.postgresql_psycopg2', + # 'NAME': 'maposmatic', + # 'USER': 'maposmatic', + # 'PASSWORD': 'secret', + # 'HOST': 'localhost', + # 'PORT': '5432' + # }, + +} + +# Path to ocitysmap's config file to use, or None for the default +# (~/.ocitysmap.conf) OCITYSMAP_CFG_PATH = None # Path to the file containing the datetime of the state of the GIS @@ -80,17 +100,10 @@ ITEMS_PER_PAGE = 25 MAPOSMATIC_PID_FILE = '/var/run/maposmaticd.pid' # Settings for exception emails: the from email address, and the list of -# receipient email addresses. No emails are sent if the receipients list is -# empty. -DAEMON_ERRORS_SMTP_HOST = 'localhost' +# receipient email addresses. No emails are sent if the SMTP host is not +# defined. +DAEMON_ERRORS_SMTP_HOST = None DAEMON_ERRORS_SMTP_PORT = 25 DAEMON_ERRORS_EMAIL_FROM = 'daemon@domain.com' DAEMON_ERRORS_EMAIL_REPLY_TO = 'noreply@domain.com' DAEMON_ERRORS_JOB_URL = 'http://domain.com/jobs/%d' - -### -## Optional: if you need to extend the python search path, then write -## something like the following: -# import sys -# sys.path.append('/path/to/ocitysmap') -# sys.path.append('/path/to/lib/python/site-packages')