From b9c97d7e3e3dfca84319fed9e53684d0e48e63f2 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sat, 8 Mar 2008 12:29:50 -0800 Subject: [PATCH] * 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 --- fas/fas/commands.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fas/fas/commands.py b/fas/fas/commands.py index 7d6c30b..dbbaf2d 100644 --- a/fas/fas/commands.py +++ b/fas/fas/commands.py @@ -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())