Exemplo n.º 1
0
    def _gen_handlers(self):
        """
        获取urlhandlers
        :return:
        """
        # import handlers
        handler_path = os.path.join(os.path.dirname(sys.argv[0]), "logic",
                                    "web", "handler")
        import_path = "logic.web.handler"
        import_handlers(handler_path, import_path)

        # register handlers
        handlers = [
            web.url(dic['uri'],
                    web.StaticFileHandler,
                    dict(path=dic['path']),
                    name=dic['name']) for dic in self.static_paths
        ]

        handlers += Route.routes()

        handlers += [url(r"/ping", HttpPingHandle, {}, "ping handler")]
        handlers += [
            url(r"/set_logger_level", SetLoggerLevelHandle, {},
                "Set Logger Level handler")
        ]
        handlers += [url(r"/doc", DocHandle, {}, "Doc handler")]
        return handlers
Exemplo n.º 2
0
    def __init__(self, port, is_https):
        # import handlers
        handler_path = os.path.join(os.path.dirname(CUR_FILE_DIR_PATH),
                                    "logic", "web", "handler")
        import_path = "logic.web.handler"
        import_handlers(handler_path, import_path)

        # register handlers
        handlers = [
            web.url(r"/static/(.+)",
                    web.StaticFileHandler,
                    dict(path=settings['static_path']),
                    name='static_path')
        ] + Route.routes()

        jinja_environment = Environment(loader=FileSystemLoader(
            settings['template_path']),
                                        auto_reload=True,
                                        autoescape=False)

        jinja_environment.filters['lt_gt'] = lambda s: s.replace(
            '<', '&lt;').replace('>', '&gt;')
        jinja_environment.globals['settings'] = settings
        super(WebApp, self).__init__(ssl_args if is_https else {},
                                     port,
                                     handlers,
                                     jinja_env=jinja_environment,
                                     **settings)
Exemplo n.º 3
0
 def import_handlers(cls):
     """
     导入mqtt接收handler
     :return:
     """
     # import handlers
     handler_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "logic", "mqtt", "handler")
     import_path = "mxadap.logic.mqtt.handler"
     import_handlers(handler_path, import_path)
Exemplo n.º 4
0
 def import_handlers(cls):
     """
     导入mqtt接收handler
     :return:
     """
     # import handlers
     handler_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "logic", "mqtt", "handler")
     import_path = "mqtt_server.logic.mqtt.handler"
     import_handlers(handler_path, import_path)
Exemplo n.º 5
0
 def init(self, args):
     """
     初始化接口
     :param args: 参数变量
     :return:
     """
     # import wechat handlers
     handler_path = os.path.join(CUR_FILE_DIR_PATH, "logic", "wechat", "handler")
     import_path = "logic.wechat.handler"
     import_handlers(handler_path, import_path)
Exemplo n.º 6
0
    def __init__(self, port, is_https):
        # import handlers
        handler_path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
            "logic", "web", "handler")
        import_path = "logic.web.handler"
        import_handlers(handler_path, import_path)

        # register handlers
        super(WebApp, self).__init__(ssl_args if is_https else {}, port,
                                     Route.routes())
Exemplo n.º 7
0
    def _gen_handlers(self):
        """
        获取urlhandlers
        :return:
        """
        # import handlers
        handler_path = os.path.join(os.path.dirname(sys.argv[0]), "logic", "web", "handler")
        import_path = "logic.web.handler"
        import_handlers(handler_path, import_path)

        # register handlers
        handlers = [web.url(dic['uri'], web.StaticFileHandler, dict(path=dic['path']), name=dic['name'])
                    for dic in self.static_paths]

        handlers += Route.routes()

        handlers += [url(r"/ping", HttpPingHandle, {}, "ping handler")]
        handlers += [url(r"/set_logger_level", SetLoggerLevelHandle, {}, "Set Logger Level handler")]
        handlers += [url(r"/doc", DocHandle, {}, "Doc handler")]
        return handlers
Exemplo n.º 8
0
singleton_abcmeta = type("singleton_abcmeta", (ABCMeta, Singleton), {})

class XMPP_APP(XMPPClient):
    """
    xmpp服务
    """
    __metaclass__ = singleton_abcmeta

    def __init__(self):
        super(XMPP_APP, self).__init__()

    def send_async(self, sto_jid, ssubject, sbody):
        """
        协程非阻塞发送
        :param sto_jid:
        :param ssubject:
        :param sbody:
        :return:
        """
        if ArgumentParser().args.use_sign:
            sbody['sign'] = XMPP_SIGN
        super(XMPP_APP, self).send_async(sto_jid, ssubject, sbody)


# import handlers
handler_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "logic", "xmpp", "handler")
import_path = "bridge.logic.xmpp.handler"
import_handlers(handler_path, import_path)