fix link to about.
# Copyright (c) 2012 netzguerilla.net <iro@netzguerilla.net>
#
# This file is part of Iro.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# #Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from twisted.application.service import Service, MultiService
from twisted.application import internet
from twisted.web import resource, server
from twisted.internet import reactor
from twisted.python import log
from sqlalchemy import create_engine, pool
import config, install
from .view import xmlrpc, jsonrpc, jsonresource, cmtelecom
from .model import setEngine, setPool
from .controller.pool import startPool, dbPool
class IroService(Service):
def startService(self):
log.msg("Starting service...")
engine = create_engine(config.main.dburl,
poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, pool_recycle=3600)
setEngine(engine)
startPool(reactor)
setPool(dbPool)
reactor.callWhenRunning(config.readConfig)
Service.startService(self)
def makeService(cfg):
top_service = MultiService()
config.confFiles.insert(0, cfg["config"])
if not install.checkConfig():
log.err("You can create a sample configuration file by running iro-install")
raise Exception("Please update or create your configuration file %s." % cfg["config"])
config.init()
if not install.checkDatabaseConnection():
raise Exception("Can't connect to database")
if not install.checkDatabase():
raise Exception("Database not in right format. Please run iro-install --install")
routes = [ s for s in config.configParser.sections() if not s in ["main",]]
ao = install.getAllRoutes(routes, False)
for o in ao["orphand"]:
log.msg("Offer(%s) is orphand (no route using this offer)."%o)
if ao["added"]:
raise Exception("offerlist is not up-to-date.\nPlease run iro-install --update")
root = resource.Resource()
cmtelecom.appendResource(root)
xmlrpc.appendResource(root)
jsonrpc.appendResource(root)
jsonresource.appendResource(root)
v2 = resource.Resource()
xmlrpc.appendResource(v2)
jsonrpc.appendResource(v2)
jsonresource.appendResource(v2)
root.putChild('1.0a', v2)
internet.TCPServer(config.main.port, server.Site(root)).setServiceParent(top_service)
IroService().setServiceParent(top_service)
return top_service