当前位置: 首页>>代码示例>>Python>>正文


Python DotDict.update方法代码示例

本文整理汇总了Python中utils.dotdict.DotDict.update方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.update方法的具体用法?Python DotDict.update怎么用?Python DotDict.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.dotdict.DotDict的用法示例。


在下文中一共展示了DotDict.update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import update [as 别名]
    def get(self):
        """Display profile of current user.
        """
        status = ErrorCode.SUCCESS
        try: 
            tid = self.get_argument('tid',None) 
            # check tid whether exist in request and update current_user
            self.check_tid(tid)

            profile = DotDict()
            # 1: user
            user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
            if not user:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("[UWEB] User does not exist, redirect to login.html. uid: %s.", 
                              self.current_user.uid)
                self.write_ret(status)
                return

            # 2: car 
            car = QueryHelper.get_car_by_tid(self.current_user.tid, self.db)            
            profile.update(user)
            profile.update(car)
            self.write_ret(status,
                           dict_=dict(profile=profile))
        except Exception as e:
            logging.exception("[UWEB] Get user profile failed. uid:%s, tid:%s, Exception: %s", 
                              self.current_user.uid, self.current_user.tid, e.args) 
            status = ErrorCode.SERVER_BUSY
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:32,代码来源:profile.py

示例2: write_ret

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import update [as 别名]
 def write_ret(self, status, message=None, dict_=None):
     """
     write back ret message: dict(status=status,
                                  message=ErrorCode.ERROR_MESSAGE[status],
                                  ...)
     """
     ret = DotDict(status=status)
     if message is None:
         ret.message = WXErrorCode.ERROR_MESSAGE[status]
     else:
         ret.message = message
     if isinstance(dict_, dict):
         ret.update(dict_)
     self.set_header(*self.JSON_HEADER)
     self.write(json_encode(ret))
开发者ID:jcsy521,项目名称:ydws,代码行数:17,代码来源:base.py

示例3: write_ret

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import update [as 别名]
    def write_ret(self, status, message=None, dict_=None):
        """
        write back ret message: dict(status=status,
                                     message=ErrorCode.ERROR_MESSAGE[status],
                                     ...)
        """
        ret = DotDict(status=status)
        if message is None:
            ret.message = ErrorCode.ERROR_MESSAGE[status]
        else:
            ret.message = message

        try:
            ret['message'] = ret['message'].encode('utf8')
        except:
            pass

        if isinstance(dict_, dict):
            ret.update(dict_)
        self.set_header(*self.JSON_HEADER)
        t = json_encode(ret)
        self.write(t)
开发者ID:jcsy521,项目名称:ydws,代码行数:24,代码来源:base.py

示例4: get

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import update [as 别名]
    def get(self):
        """Get terminal info.
        """
        status = ErrorCode.SUCCESS
        try:
            tid = self.get_argument('tid', None)
            # check tid whether exist in request and update current_user
            self.check_tid(tid)

            car_sets = DotDict()

            terminal = QueryHelper.get_available_terminal(self.current_user.tid, self.db)
            if not terminal:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("[UWEB] The terminal with tid: %s does not exist,"
                              "  redirect to login.html",
                              self.current_user.tid)
                self.write_ret(status)
                return

            user = QueryHelper.get_user_by_mobile(terminal.owner_mobile, self.db)
            if not user:
                logging.error("[UWEB] The user with uid: %s does not exist,"
                              "  redirect to login.html", 
                              self.current_user.uid)
                self.clear_cookie(self.app_name)
                self.write_ret(ErrorCode.LOGIN_AGAIN)
                return

            # NOTE: deprecated.
            if terminal['mannual_status'] == 1:
                terminal['parking_defend'] = 0
            else:
                terminal['parking_defend'] = 1

            # NOTE: deprecated.
            whitelist = QueryHelper.get_white_list_by_tid(
                self.current_user.tid, self.db)

            car_info = QueryHelper.get_car_by_tid(
                self.current_user.tid, self.db)
            car = dict(corp_cnum=car_info.get('cnum', ''))

            # add tow dict: terminal, car. add two value: whitelist_1,
            # whitelist_2
            white_list = [terminal.owner_mobile]
            for item in whitelist:
                white_list.append(item['mobile'])

            car_sets.update(terminal)
            car_sets.update(car)
            car_sets.update(DotDict(white_list=white_list))
            self.write_ret(status,
                           dict_=dict(car_sets=car_sets))
        except Exception as e:
            status = ErrorCode.SERVER_BUSY
            logging.exception("[UWEB] uid: %s tid: %s get terminal failed. Exception: %s",
                              self.current_user.uid, self.current_user.tid, e.args)
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:61,代码来源:terminal.py

示例5: get

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import update [as 别名]
    def get(self):
        """Get terminal info.
        """
        status = ErrorCode.SUCCESS
        try:
            tid = self.get_argument('tid', None)
            # check tid whether exist in request and update current_user
            self.check_tid(tid)

            # part 1: terminal
            tracker = DotDict()
            # 1: terminal
            # NOTE: static_val, move_val are deprecated
            terminal = QueryHelper.get_available_terminal(
                self.current_user.tid, self.db)

            if not terminal:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("The terminal with tid: %s does not exist, redirect to login.html", 
                              self.current_user.tid)
                self.write_ret(status)
                return

            # 撤防,智能设防
            if terminal['mannual_status'] != UWEB.DEFEND_STATUS.YES:
                terminal['parking_defend'] = 1
            else:  # 强力设防
                terminal['parking_defend'] = 0

            # 2: sos is deprecatd
            user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
            if not user:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("The user with uid: %s does not exist, redirect to login.html", 
                              self.current_user.uid)
                self.write_ret(status)
                return

            sos = dict(mobile='')
            tracker.update(sos)

            tracker.update(dict(push_status=terminal.push_status))
            tracker.update(dict(sos_pop=terminal.white_pop))
            tracker.update(dict(vibl=terminal.vibl))
            tracker.update(dict(static_val=terminal.static_val))
            tracker.update(dict(parking_defend=terminal.parking_defend))
            tracker.update(dict(owner_mobile=terminal.owner_mobile))
            tracker.update(dict(speed_limit=terminal.speed_limit))

            # part 2: profile

            profile = DotDict()

            car = QueryHelper.get_car_by_tid(self.current_user.tid, self.db)

            profile.update(dict(name=user.name,
                                mobile=user.mobile,
                                email=user.email,
                                cnum=car.cnum))

            # part 3: sms option
            sms_options = QueryHelper.get_sms_option(user.mobile, self.db)

            # part 5: corp info
            corp = DotDict()
            corp = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)

            self.write_ret(status,
                           dict_=dict(tracker=tracker,
                                      sms_options=sms_options,
                                      profile=profile,
                                      corp=corp))
        except Exception as e:
            status = ErrorCode.SERVER_BUSY
            logging.exception("[UWEB] Get appsetting failed. uid: %s tid: %s, Exception: %s",
                              self.current_user.uid, self.current_user.tid, e.args)
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:79,代码来源:appsettings.py


注:本文中的utils.dotdict.DotDict.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。