コード例 #1
0
    imei_timer_mgr = imei_timer.ImeiTimer()
    unreply_msg_mgr = unreply_msg2.UnreplyMsgMgr2()
    # no_heart_msg_mgr = noheart_msg.NoHeartMsgMgr()
    IOLoop.current().run_sync(_async_init)
    msg_rpc = MsgRPC(SysConfig.current().get(sys_config.SC_MSG_RPC_URL))

    term_rpc = terminal_rpc.TerminalRPC(SysConfig.current().get(
        sys_config.SC_TERMINAL_RPC_URL))
    handler = terminal_handler.TerminalHandler(
        conn_mgr,
        debug,
        imei_timer_mgr,
        op_log_dao=OPLogDAO.new(mongo_meta=mongo_conf.op_log_mongo_meta),
        broadcastor=broadcastor,
        pet_dao=PetDAO.new(mongo_meta=mongo_conf.op_log_mongo_meta),
        user_dao=UserDAO.new(mongo_meta=mongo_conf.op_log_mongo_meta),
        new_device_dao=NewDeviceDAO.new(
            mongo_meta=mongo_conf.op_log_mongo_meta),
        msg_rpc=msg_rpc,
        device_setting_mgr=device_setting_mgr.DeviceSettingMgr(
            NewDeviceDAO.new(mongo_meta=mongo_conf.op_log_mongo_meta)),
        unreply_msg_mgr=unreply_msg_mgr,
        # no_heart_msg_mgr=no_heart_msg_mgr
        terminal_rpc=term_rpc)

    conn_mgr.CreateTcpServer("", listen_port, handler)
    webapp = Application(
        [(r"/op_log", http_handlers.GetOpLogHandler),
         (r"/send_command", http_handlers.SendCommandHandler),
         (r"/send_command2", http_handlers.SendCommandHandler2),
         (r"/send_command3", http_handlers.SendCommandHandler3),
コード例 #2
0
ファイル: main.py プロジェクト: newguangzhou/now-hello
        (r"/pet/activity", handlers.PetActivity),
        (r"/device/add_device_info", handlers.AddDeviceInfo),
        (r"/device/get_info", handlers.GetDeviceInfo),
        (r"/device/remove_device_info", handlers.RemoveDeviceInfo),
        (r"/device/set_sim_info", handlers.SetSimInfo),
        #(r"/device/switch_light", handlers.SwitchLight),
        #        (r"/device/get_light_status", handlers.GetDeviceSwitchLightStatus),
        (r"/device/send_get_wifi_list_cmd", handlers.SendGetWifiListCmd),
        (r"/device/get_wifi_list", handlers.GetWifiList),
        #(r"/device/reboot_device_cmd", handlers.RebootDeviceCmd),
        (r"/device/get_device_status", handlers.GetPetStatusInfo),
        (r"/app/get_config", handlers.AppConfig),
    ],
    autoreload=True,
    debug=True,
    user_dao=UserDAO.new(mongo_meta=mongo_conf.user_mongo_meta),
    global_dao=GlobalDAO.new(mongo_meta=mongo_conf.global_mongo_meta),
    auth_dao=AuthDAO.new(mongo_meta=mongo_conf.auth_mongo_meta),
    pet_dao=PetDAO.new(mongo_meta=mongo_conf.pet_mongo_meta),
    device_dao=NewDeviceDAO.new(mongo_meta=mongo_conf.pet_mongo_meta),
    appconfig=conf,
)


class _UserSrvConsole(Console):
    def handle_cmd(self, stream, address, cmd):
        if len(cmd) == 1 and cmd[0] == "quit":
            self.send_response(stream, "Byte!")
            return False
        elif len(cmd) == 0:
            pass
コード例 #3
0
thread_pool = ThreadPoolExecutor(max_thread_count)
mongo_client = GetMongoClientAndAuth(mongo_conf.default_meta)



# Init web application
webapp = Application(
    [
        (r"/file/pet/upload_logo", handlers.user.upload_logo.UploadLogo),
        (r"/file/get", handlers.get.Get),
    ],
    autoreload=False,
    pyloader=pyloader,
    files_dao=FilesDAO.new( mongo_client, thread_pool),
    auth_dao=AuthDAO.new( mongo_client, thread_pool),
    user_dao=UserDAO.new( mongo_client, thread_pool),
    appconfig=conf, )


class _UserSrvConsole(Console):
    def handle_cmd(self, stream, address, cmd):
        if len(cmd) == 1 and cmd[0] == "quit":
            self.send_response(stream, "Byte!")
            return False
        elif len(cmd) == 0:
            pass
        elif len(cmd) == 1 and cmd[0] == "reload-config":
            newconf = pyloader.ReloadInst("Config")
            webapp.settings["appconfig"] = newconf
            self.send_response(stream, "done")
        elif len(cmd) == 1 and cmd[0] == "reload-sysconfig":