* Reference os.path commands with os.path namespace.

* Add check that dev.cfg exists before using it.
* Change production config name to fas.cfg
* Look for the config file in /etc
This commit is contained in:
Toshio Kuratomi 2008-03-08 12:29:50 -08:00
parent 8fb37de888
commit b9c97d7e3e

View file

@ -4,8 +4,6 @@
import os
import sys
from os.path import dirname, exists, join
import pkg_resources
pkg_resources.require("TurboGears")
@ -18,9 +16,8 @@ class ConfigurationError(Exception):
pass
def start():
"""Start the CherryPy application server."""
setupdir = dirname(dirname(__file__))
'''Start the CherryPy application server.'''
setupdir = os.path.dirname(os.path.dirname(__file__))
curdir = os.getcwd()
# First look on the command line for a desired config file,
@ -32,10 +29,13 @@ def start():
# 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")
elif os.path.exists(os.path.join(setupdir, 'setup.py')) \
and os.path.exists(os.path.join(setupdir, 'dev.cfg')):
configfile = os.path.join(setupdir, 'dev.cfg')
elif os.path.exists(os.path.join(curdir, 'fas.cfg')):
configfile = os.path.join(curdir, 'fas.cfg')
elif os.path.exists(os.path.join('/etc/fas.cfg')):
configfile = os.path.join('/etc/fas.cfg')
else:
try:
configfile = pkg_resources.resource_filename(
@ -48,5 +48,4 @@ def start():
modulename="fas.config")
from fas.controllers import Root
turbogears.start_server(Root())