-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
34 lines (28 loc) · 1006 Bytes
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from ConfigParser import SafeConfigParser as ConfigParser
import os
from cubes import server
def read_slicer_config(config):
if not config:
return ConfigParser()
elif isinstance(config, basestring):
try:
path = config
config = ConfigParser()
config.read(path)
except Exception as e:
raise Exception("Unable to load configuration: %s" % e)
return config
def setup_config(config):
config = read_slicer_config(config)
# set server configurations: port
config.set("server", "port", os.environ.get('PORT') or '5000')
# set store configurations
config.add_section('store')
config.set("store", "type", "sql")
if os.environ.get('CG_URL'):
config.set("store", "url", os.environ.get('CG_URL'))
else:
raise Exception("No Database URL found. Please export CG_URL=postress://etc...")
return config
config = setup_config('slicer.ini')
application = server.create_server(config)