Exemplo n.º 1
0
# Init web application
webapp = Application(
    [
        (r"/msg/send_sms", handlers.SendSMS),
        (r"/msg/send_verify_code", handlers.SendVerify),
        (r"/msg/push_android", handlers.PushAndrod),
        (r"/msg/push_all", handlers.PushAll),
        (r"/msg/push_ios", handlers.PushIOS),
        (r"/msg/push", handlers.Push)
    ],
    autoreload=True,
    pyloader=pyloader,
    appconfig=conf,
    sms_registered=True,
    auth_dao=AuthDAO.new(mongo_client, thread_pool),
    sms_sender=send_message,
    verify_sender=send_verify,
    xiaomi_push2= MiPush2(conf.mipush_appsecret_android, conf.mipush_pkg_name,
                          conf.mipush_appsecret_ios, conf.mipush_bundle_id, True),
    xiaomi_push=MIPush(conf.mipush_host, conf.mipush_appsecret_android,
                       conf.mipush_pkg_name))


try:
    worker.register(discover_config.MSG_SRV_D, options.port, 0, None)
    worker.work()
except Exception, e:
    print "worker register error exception:", e
    logger.exception(e)
    exit(0)
Exemplo n.º 2
0
        (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
        elif len(cmd) == 1 and cmd[0] == "reload-config":
            newconf = loadJsonConfig()