Example #1
0
    def rawDataReceived(self, rawData):

        data = self.protocol.received(rawData)

        if data == b"\x03\xe9":
            LOG.info("client was closed")
            self.session.quit()
        else:
            self.session.process(data.decode())
Example #2
0
 def get_module(self, module):
     for url in self.urls:
         LOG.info("url 0 [ %s ] , module [ %s ]" % (url[0], module))
         if url[0] == module:
             LOG.debug("found it " + url[1]["target"])
             module = _import(url[1]["target"])
             return module
     else:
         LOG.error("not found module named %s in file setting" % module)
Example #3
0
    def process(self, data):
        data = self.handle_request_data(data)
        ret = self.parse_response(self.execute(data))
        if not ret:
            LOG.info("no returned data")
            return

        for (session, data) in self.iterate_response_data(ret):
            session.send(data)
Example #4
0
    def __init__(self, potocol, factory):
        self.protocol = potocol
        self.factory = factory
        self.attr = {}
        self.header = self.protocol.header
        self.sendto = None
        self.send_queue = deque()
        self.triggered = False

        if hasattr(self.protocol, "factory"):
            config = self.protocol.factory.config
            self.project, self.module = config.get_module(self.header.path)
            LOG.info("session belong to project " + self.project.name)
            self.apps = self.project.apps
Example #5
0
    def add_app(self, key, value):
        self.apps[key] = value
        return value

    def get_app(self, key, default=None):
        if key not in self.apps and default is not None:
            self.apps[key] = default
        return self.apps.get(key, None)

    def get_conf(self, key):
        print("get conf %s and val %s" %
              (key, self.module.__dict__.get(key, None)))
        return self.module.__dict__.get(key, None)

    def get_module(self, module):
        for url in self.urls:
            LOG.info("url 0 [ %s ] , module [ %s ]" % (url[0], module))
            if url[0] == module:
                LOG.debug("found it " + url[1]["target"])
                module = _import(url[1]["target"])
                return module
        else:
            LOG.error("not found module named %s in file setting" % module)


if __name__ == '__main__':
    LOG.info("cloudbreath startup")
    reactor.listenTCP(setting.PORT, WebsocketFactory(Config(setting.webroot)))
    reactor.run()