Don't crash if we couldn't import ExMachina.

This commit is contained in:
Nick Daly 2013-03-23 18:45:07 -05:00
parent bef0bcecca
commit ea49a08675

View File

@ -17,7 +17,6 @@ from util import *
from logger import Logger from logger import Logger
#from modules.auth import AuthController, require, member_of, name_is #from modules.auth import AuthController, require, member_of, name_is
from exmachina import ExMachinaClient
import socket import socket
__version__ = "0.2.14" __version__ = "0.2.14"
@ -99,6 +98,11 @@ def setup():
except AttributeError: except AttributeError:
pass pass
try:
from exmachina import ExMachinaClient
except ImportError:
cfg.exmachina = None
else:
try: try:
cfg.exmachina = ExMachinaClient( cfg.exmachina = ExMachinaClient(
secret_key=cfg.exmachina_secret_key or None) secret_key=cfg.exmachina_secret_key or None)
@ -124,7 +128,8 @@ def setup():
server.subscribe() server.subscribe()
# Configure default server # Configure default server
cherrypy.config.update({'server.socket_host': cfg.host, cherrypy.config.update(
{ 'server.socket_host': cfg.host,
'server.socket_port': cfg.port, 'server.socket_port': cfg.port,
'server.thread_pool':10, 'server.thread_pool':10,
'tools.staticdir.root': cfg.file_root, 'tools.staticdir.root': cfg.file_root,
@ -132,8 +137,8 @@ def setup():
'tools.auth.on':True, 'tools.auth.on':True,
'tools.sessions.storage_type':"file", 'tools.sessions.storage_type':"file",
'tools.sessions.timeout':90, 'tools.sessions.timeout':90,
'tools.sessions.storage_path':"%s/data/cherrypy_sessions" % cfg.file_root, 'tools.sessions.storage_path':
"%s/data/cherrypy_sessions" % cfg.file_root,
}) })
config = {'/': {'tools.staticdir.root': '%s/static' % cfg.file_root, config = {'/': {'tools.staticdir.root': '%s/static' % cfg.file_root,
@ -141,8 +146,8 @@ def setup():
'/static': {'tools.staticdir.on': True, '/static': {'tools.staticdir.on': True,
'tools.staticdir.dir':"."}, 'tools.staticdir.dir':"."},
'/favicon.ico':{'tools.staticfile.on':True, '/favicon.ico':{'tools.staticfile.on':True,
'tools.staticfile.filename': "%s/static/theme/favicon.ico" % cfg.file_root} 'tools.staticfile.filename':
} "%s/static/theme/favicon.ico" % cfg.file_root}}
cherrypy.tree.mount(cfg.html_root, '/', config=config) cherrypy.tree.mount(cfg.html_root, '/', config=config)
cherrypy.engine.signal_handler.subscribe() cherrypy.engine.signal_handler.subscribe()