示例#1
0
def make_server(cass):
    setup_tasks(cass)
    root = Resource()
    root.putChild("", Polites(cass))
    root.putChild("snapshot", SnapShot(cass))
    root.putChild("restore", Restore(cass))
    www_path = find_www()
    if www_path:
        root.putChild("docs", File(www_path))
    application = Site(root)

    try:
        handle_tune(cass)
    except IOError:
        LOGGER.exception("[make_server] unable to set configuration")
    reactor.callLater(0, cass.find_snapshot)
    reactor.listenTCP(cass.config.default_web_port, application)
    run()
示例#2
0
 def test_find_www(self):
     with mock.patch.object(utils.os.path, 'exists', mock.MagicMock()):
         self.assertEqual(utils.find_www(),
                          os.path.join('/var', 'www', 'polites'))