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


Python QueryHelper.get_terminal_basic_info方法代码示例

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


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

示例1: push

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_basic_info [as 别名]
 def push(self, packet):
     start_time = time.time()
     t = int(time.time()) * 1000
     t_info = QueryHelper.get_terminal_basic_info(self.tid, self.db)
     uid = t_info.get('umobile','')
     cid = t_info.get('cid','') 
     lst = [] 
     if uid: 
         lst.append(uid) 
     if cid: 
         lst.append(cid) 
     for item in set(lst):
         push_key = get_push_key(item, t)
         res = WSPushHelper.push(item, t, push_key, packet, self.redis) 
         end_time = time.time()
         print "push time: %s" % (end_time - start_time)
         print res
开发者ID:jcsy521,项目名称:ydws,代码行数:19,代码来源:wspush.py

示例2: push_packet

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_basic_info [as 别名]
    def push_packet(tid, packet, db, redis, t_info=None):
        """Push packet to tid.

        :arg tid: string
        :arg db: database instance 
        :arg redis: redis instance
        :arg t_info: dict, e.g.

            {
               'tid':'',
               'umobile':'',
               'group_id':'',
               'cid':'',
               'oid':[]
            }
 
        """
        # NOTE: t_info has higher priority compared with tid
        if not t_info:  # tid is avaliable
            t_info = QueryHelper.get_terminal_basic_info(tid, db)

        uid = t_info.get('umobile', '')
        cid = t_info.get('cid', '')
        oid = t_info.get('oid', [])

        t = int(time.time()) * 1000

        lst = []

        if uid:
            lst.append(uid)
        if cid:
            lst.append(cid) 
        if oid:
            lst.extend(oid)   

        for item in set(lst):      
            push_key = get_push_key(item, t)
            res = WSPushHelper.push(item, t, push_key, packet, redis)
开发者ID:jcsy521,项目名称:ydws,代码行数:41,代码来源:wspushhelper.py

示例3: delete_terminal_new

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_basic_info [as 别名]
def delete_terminal_new(tid, db, redis, del_user=True):
    """Delete terminal from platform and clear the associated info.
    """
    terminal = db.get("SELECT mobile, owner_mobile, group_id FROM T_TERMINAL_INFO"
                      "  WHERE tid = %s", tid)
    if not terminal:
        logging.info("Terminal: %s already does not exist, do nothing.", tid)
        return
    else:
        t_info = QueryHelper.get_terminal_basic_info(tid, db)
        # NOTE: record the del action.
        corp = QueryHelper.get_corp_by_gid(terminal.group_id, db)
        bind_info = dict(tid=tid,
                         tmobile=terminal.mobile,
                         umobile=terminal.owner_mobile,
                         group_id=terminal.group_id,
                         cid=corp.get('cid', '') if corp else '',
                         del_time=int(time.time()))
        record_del_action(bind_info, db)
        WSPushHelper.pushS3(tid, db, redis, t_info)
        clear_data(tid, db, redis)
        logging.info("[PUBLIC] Delete Terminal: %s, tmobile: %s, umobile: %s",
                     tid, terminal.mobile, terminal.owner_mobile)
开发者ID:jcsy521,项目名称:ydws,代码行数:25,代码来源:public.py

示例4: record_manual_status

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_basic_info [as 别名]
def record_manual_status(db, redis, tid, mannual_status):
    """Record the mannual_status of one terminal.

    @params: db
    @params: redis 
    @params: tid 
    @params: mannual_status 

    """

    terminal = QueryHelper.get_terminal_basic_info(tid, db)
    db.execute("INSERT INTO T_MANUAL_LOG(tid, tmobile, umobile,"
               "    group_id, cid, manual_status, timestamp)"
               "  VALUES(%s, %s, %s, %s, %s, %s, %s)",
               terminal.get('tid', ''),
               terminal.get('tmobile', ''),
               terminal.get('umobile', ''),
               terminal.get('group_id', -1),
               terminal.get('cid', ''),
               mannual_status,
               int(time.time()))

    logging.info("[PUBLIC] Record the mannual status, tid: %s, mannual_status: %s",
                 tid, mannual_status)
开发者ID:jcsy521,项目名称:ydws,代码行数:26,代码来源:public.py

示例5: pushS3

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_basic_info [as 别名]
    def pushS3(tid, db, redis, t_info=None):
        """
        S3
        Information about organization.

        :arg tid: string
        :arg db: database instance
        :arg redis: redis instance
        :arg t_info: dict, record the terminal's basic info. it has higher privilege then tid. e.g.

            {
                'tid':'',
                'umobile':'',
                'group_id':'',
                'cid':''
            }

        group_1=dict(group_id=1,
                     group_name='jia',
                     tids=['tid1',
                           'tid2', 
                           'tid3'])

        group_2=dict(group_id=2,
                     group_name='jia',
                     tids=['tid1',
                           'tid2', 
                           'tid3'])
        res = []
        res.append(group_1)
        res.append(group_2)
        """
        res = []
        if not t_info:  # tid is avaliable
            t_info = QueryHelper.get_terminal_basic_info(tid, db)

        cid = t_info.get('cid', '')

        groups = db.query("SELECT * FROM T_GROUP WHERE corp_id = %s",
                          cid)
        for group in groups:
            terminals = db.query("SELECT * FROM T_TERMINAL_INFO"
                                 "  WHERE group_id = %s "
                                 "  AND service_status= 1",  # only success
                                 group['id'])

            tids = []
            for terminal in terminals:
                t = QueryHelper.get_terminal_info(terminal['tid'], db, redis)
                dct = dict(tid=terminal['tid'],
                           biz_type=t.get('biz_type', 0))
                tids.append(dct)

            res.append(dict(group_id=group['id'],
                            group_name=group['name'],
                            tids=tids,
                            ))

        packet = dict(packet_type="S3",
                      res=res)

        res = WSPushHelper.push_packet(tid, packet, db, redis, t_info)
开发者ID:jcsy521,项目名称:ydws,代码行数:64,代码来源:wspushhelper.py

示例6: delete

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_basic_info [as 别名]
    def delete(self):
        """Delete a terminal.
        """
        try:
            status = ErrorCode.SUCCESS
            tid = self.get_argument('tid', None)
            flag = self.get_argument('flag', 0)
            logging.info("[UWEB] Corp delete terminal request. tid: %s, flag: %s, cid: %s",
                         tid, flag, self.current_user.cid)

            terminal = QueryHelper.get_available_terminal(tid, self.db)
            if not terminal:
                logging.error("[UWEB] The terminal with tid: %s does not exist!", 
                              tid)
                status = ErrorCode.TERMINAL_NOT_EXISTED
                self.write_ret(status)
                return

            t_info = QueryHelper.get_terminal_basic_info(tid, self.db)
            key = get_del_data_key(tid)
            self.redis.set(key, flag)
            biz_type = QueryHelper.get_biz_type_by_tmobile(
                terminal.mobile, self.db)
            if int(biz_type) == UWEB.BIZ_TYPE.YDWS:
                if terminal.login != GATEWAY.TERMINAL_LOGIN.ONLINE:
                    if terminal.mobile == tid:
                        delete_terminal(tid, self.db, self.redis)
                    else:
                        status = self.send_jb_sms(
                            terminal.mobile, terminal.owner_mobile, tid)

                    if status == ErrorCode.SUCCESS:
                        WSPushHelper.pushS3(tid, self.db, self.redis, t_info)
                    self.write_ret(status)
                    return
            else:
                delete_terminal(tid, self.db, self.redis)
                if status == ErrorCode.SUCCESS:
                    WSPushHelper.pushS3(tid, self.db, self.redis, t_info)
                self.write_ret(status)
                return

            # unbind terminal
            seq = str(int(time.time() * 1000))[-4:]
            args = DotDict(seq=seq,
                           tid=tid)
            response = GFSenderHelper.forward(GFSenderHelper.URLS.UNBIND, args)
            response = json_decode(response)
            logging.info(
                "[UWEB] UNBind terminal: %s, response: %s", tid, response)
            if response['success'] == ErrorCode.SUCCESS:
                logging.info("[UWEB] uid:%s, tid: %s, tmobile:%s GPRS unbind successfully",
                             self.current_user.uid, tid, terminal.mobile)
            else:
                status = response['success']
                # unbind failed. clear sessionID for relogin, then unbind it
                # again
                clear_sessionID(self.redis, tid)
                logging.error('[UWEB] uid:%s, tid: %s, tmobile:%s GPRS unbind failed, message: %s, send JB sms...',
                              self.current_user.uid, tid, terminal.mobile,
                              ErrorCode.ERROR_MESSAGE[status])
                status = self.send_jb_sms(
                    terminal.mobile, terminal.owner_mobile, tid)

            if status == ErrorCode.SUCCESS:
                WSPushHelper.pushS3(tid, self.db, self.redis, t_info)
            self.write_ret(status)
        except Exception as e:
            logging.exception("[UWEB] Delete terminal failed. cid: %s, Exception: %s",
                              self.current_user.cid, e.args)
            status = ErrorCode.SERVER_BUSY
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:74,代码来源:terminal.py


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