2008-06-09 00:58:23 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""This module contains functions called from console script entry points."""
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from os import getcwd
|
|
|
|
from os.path import dirname, exists, join
|
|
|
|
|
|
|
|
import pkg_resources
|
|
|
|
pkg_resources.require("TurboGears>=1.0.4.4")
|
|
|
|
|
|
|
|
import cherrypy
|
|
|
|
import turbogears
|
|
|
|
|
|
|
|
cherrypy.lowercase_api = True
|
|
|
|
|
|
|
|
|
|
|
|
class ConfigurationError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def start():
|
|
|
|
"""Start the CherryPy application server."""
|
|
|
|
|
|
|
|
setupdir = dirname(dirname(__file__))
|
|
|
|
curdir = getcwd()
|
|
|
|
|
|
|
|
# First look on the command line for a desired config file,
|
|
|
|
# if it's not on the command line, then look for 'setup.py'
|
|
|
|
# in the current directory. If there, load configuration
|
|
|
|
# from a file called 'dev.cfg'. If it's not there, the project
|
|
|
|
# is probably installed and we'll look first for a file called
|
|
|
|
# 'prod.cfg' in the current directory and then for a default
|
|
|
|
# config file called 'default.cfg' packaged in the egg.
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
configfile = sys.argv[1]
|
|
|
|
elif exists(join(setupdir, "setup.py")):
|
|
|
|
configfile = join(setupdir, "dev.cfg")
|
|
|
|
elif exists(join(curdir, "prod.cfg")):
|
|
|
|
configfile = join(curdir, "prod.cfg")
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
configfile = pkg_resources.resource_filename(
|
2008-08-23 15:11:19 +02:00
|
|
|
pkg_resources.Requirement.parse("fotokiosk"),
|
2008-06-09 00:58:23 +02:00
|
|
|
"config/default.cfg")
|
|
|
|
except pkg_resources.DistributionNotFound:
|
|
|
|
raise ConfigurationError("Could not find default configuration.")
|
|
|
|
|
|
|
|
turbogears.update_config(configfile=configfile,
|
2008-08-23 15:11:19 +02:00
|
|
|
modulename="fotokiosk.config")
|
2008-06-09 00:58:23 +02:00
|
|
|
|
2008-08-23 15:11:19 +02:00
|
|
|
from fotokiosk.controllers import Root
|
2008-06-09 00:58:23 +02:00
|
|
|
|
|
|
|
turbogears.start_server(Root())
|