コード例 #1
0
ファイル: main.py プロジェクト: jl789/oef-search-pluto
    def __init__(self):
        #self.world = World.World()
        self.grid = EnglandGrid.EnglandGrid()
        self.grid.load()

        oef_agent_factory = OefAgentFactory()

        search_network = SearchNetwork(oef_agent_factory.connection_factory, self.grid.entities)
        search_network.build_from_entities(self.grid.entities)

        self.agents = CrawlerAgents.CrawlerAgents(oef_agent_factory, self.grid)
        self.app = bottle.Bottle()
コード例 #2
0
    def __init__(self, args):
        self.search_network = SearchNetwork.SearchNetwork()
        self.connection_factory = ConnectionFactory.ConnectionFactory()

        self.app = bottle.Bottle()

        self.server = ThreadedWebserver.ThreadedWebserver(7500, self.app)
        self.server.run()

        for i in [0, 1, 2, 3]:
            self.search_network.add_stack("oef-{}".format(i),
                                          "search-{}".format(i),
                                          communication_handler=None)
コード例 #3
0
    def testKill(self):
        app = bottle.Bottle()
        app.route('/', method='GET', callback=functools.partial(self.getRoot))

        foo = ThreadedWebserver.ThreadedWebserver(7500, app)
        foo.run()

        time.sleep(1)

        r = requests.get('http://127.0.0.1:7500/')

        foo.stop()

        assert r.text == "Hello"
コード例 #4
0
ファイル: main.py プロジェクト: jl789/oef-search-pluto
    def run(self, args):
        self.grid = EnglandGrid.EnglandGrid()
        self.grid.load()

        self.server = bottle.Bottle()
        self.server.route('/',
                          method='GET',
                          callback=functools.partial(self.getRoot))
        self.server.route('/svg',
                          method='GET',
                          callback=functools.partial(self.getSVG))
        self.server.route('/pop',
                          method='GET',
                          callback=functools.partial(self.getPop))
        self.server.route('/genpop',
                          method='GET',
                          callback=functools.partial(self.genPop))
        self.server.run(host="0.0.0.0", port=args.http_port)
コード例 #5
0
def http_server(host: str,
                port: int,
                crt_file: str,
                *,
                router: BackendRouter,
                html_dir: str = None):
    app = bottle.Bottle()
    srv = SSLWSGIRefServer.SSLWSGIRefServer(host="0.0.0.0",
                                            port=port,
                                            certificate_file=crt_file)
    app.route(path="/json/<path:path>",
              method="POST",
              callback=http_json_handler(router))
    if html_dir is not None:
        app.route(path="/website/<path:path>",
                  method="GET",
                  callback=partial(serve_site, html_dir))
        app.route(path="/",
                  method="GET",
                  callback=partial(serve_site, html_dir, "index.html"))
    bottle.run(server=srv, app=app)
コード例 #6
0
def http_server(host: str,
                port: int,
                crt_file: str,
                *,
                router: BackendRouter,
                html_dir: str = None,
                config: dict = {}):
    app = bottle.Bottle()
    logger.warning("BOTTLE app created.")
    if len(crt_file) > 0:
        srv = SSLWSGIRefServer.SSLWSGIRefServer(host="0.0.0.0",
                                                port=port,
                                                certificate_file=crt_file)
    else:
        srv = ThreadedWebserver.MyServer(host="0.0.0.0", port=port)
    logger.warning("SSL wrapper created.")
    app.route(path="/json/<path:path>",
              method="POST",
              callback=http_json_handler(router))
    if html_dir is not None:
        logger.warning("html_dir will be served.")
        app.route(path="/website/<path:path>",
                  method="GET",
                  callback=partial(serve_site, html_dir))
        app.route(path="/",
                  method="GET",
                  callback=partial(serve_site, html_dir, "index.html"))

    if config:
        if 'prometheus_api_path' in config:
            logger.warning("prometheus api will be served.")
            app.route(path=config['prometheus_api_path'],
                      method="GET",
                      callback=partial(serve_stats,
                                       config['prometheus_log_file'],
                                       config['search_prometheus_log_file']))
    if len(crt_file) > 0:
        bottle.run(server=srv, app=app)
    else:
        srv.run(app)