Better handling of configuration file
authorSimo Sorce <simo@redhat.com>
Thu, 13 Mar 2014 20:05:46 +0000 (16:05 -0400)
committerSimo Sorce <simo@redhat.com>
Thu, 13 Mar 2014 20:06:40 +0000 (16:06 -0400)
allow to pass it on the command line or to look for it in well known
locations.

Signed-off-by: Simo Sorce <simo@redhat.com>
ipsilon/idpserver.py

index f9fb527..beb1a92 100755 (executable)
@@ -28,7 +28,17 @@ from ipsilon.util import page
 from ipsilon.root import Root
 from jinja2 import Environment, FileSystemLoader
 
-cherrypy.config.update('ipsilon.conf')
+cfgfile = None
+if (len(sys.argv) > 1):
+    cfgfile = sys.argv[-1]
+elif os.path.isfile('ipsilon.conf'):
+    cfgfile = 'ipsilon.conf'
+elif os.path.isfile('/etc/ipsilon/ipsilon.conf'):
+    cfgfile = '/etc/ipsilon/ipsilon.conf'
+else:
+    raise IOError("Configuration file not found")
+
+cherrypy.config.update(cfgfile)
 
 datastore = Store()
 admin_config = datastore.get_admin_config()