def post(self): db = self.application.db self.application.settings['tunnel'] = utils.list2dict( db.query(Tunnel).all()) log.info('Tunnel cache successfully updated.') return self.success({"message": "Tunnel cache successfully updated"})
# Initializing if __name__ == "__main__": # Logs logging.config.dictConfig(settings.LOGGING) # Routes routes = [] for module in settings.REST_MODULES: routes += get_routes(__import__(module)) # DB db = databases.DB().get_instance() # App app = Application(routes, db=db, settings={ 'config': utils.list2dict(db.query(Config).all()), 'tunnel': utils.get_tunnel_map(db), 'auth': utils.get_auth_map(db), 'auth_la': utils.get_auth_la_map(db), 'prebilling': utils.get_prebilling_map(db), } ) # Start tornado with multiple processes server = HTTPServer(app) server.bind(int(port)) server.start(int(settings.TORNADO_SOCKETS)) tornado.ioloop.IOLoop.instance().start()
from application.src import databases # Settings partner_name = 'tim/fit' api_version = 'v1' # Logging handler logging.config.dictConfig(settings.LOGGING) log = logging.getLogger(__name__) LOG_MO = settings.LOG_HASHES[partner_name]["mo"] # DB db = databases.DB().get_instance() # Configs configs = utils.list2dict(db.query(Config).all()) class MoService(object): @staticmethod def get_configs(): """ Returns MO configs. :return: dict (with all necessary MO configs) """ return { 'hosts': [ configs['tim/fit/v1/smpp/host/1']['value'], configs['tim/fit/v1/smpp/host/2']['value'], ],
# Routes routes = [] for module in app_settings.SOAP_MODULES: soap_routes = get_soap_routes(__import__(module)) for route in soap_routes: path = route[0].lstrip('/') handler = route[1] routes += [(path, handler)] # DB db = databases.DB().get_instance() # App ws = WebService(routes, db=db, settings={ 'config': utils.list2dict(db.query(Config).all()), 'tunnel': utils.list2dict(db.query(Tunnel).all()), 'auth': utils.get_auth_map(db), 'auth_la': utils.get_auth_la_map(db), 'prebilling': utils.get_prebilling_map(db), }) application = tornado.httpserver.HTTPServer(ws) # Start tornado with multiple processes server = HTTPServer(application) server.bind(int(port)) server.start(int(app_settings.TORNADO_SOCKETS)) tornado.ioloop.IOLoop.instance().start()
def get(self): db = self.application.db configs = utils.list2dict(db.query(Config).all()) return self.success(configs)
def get(self): db = self.application.db tunnels = utils.list2dict(db.query(Tunnel).all()) return self.success(tunnels)
def post(self): db = self.application.db self.application.settings['config'] = utils.list2dict( db.query(Config).all()) log.info("Config cache successfully updated.") return self.success({"message": "Config cache successfully updated"})