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


Python QueryHelper.get_terminal_info方法代码示例

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


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

示例1: pushS4

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def pushS4(self, op):
        """
        res = []
        res.append(dict(tid='tid1',
                        login_status=1))
        res.append(dict(tid='tid2',
                        login_status=2))
        """

        res = [] 
        corp = self.db.get("SELECT * FROM V_TERMINAL where tid = %s",
                            self.tid) 
        if corp:
            terminals = self.db.query("SELECT tid FROM V_TERMINAL WHERE cid= %s",
                                      corp['cid'])
            for terminal in terminals:
                t = QueryHelper.get_terminal_info(terminal['tid'], self.db, self.redis) 
                res.append(dict(tid=terminal['tid'],
                                biz_type=0,
                                login_status=t['login']))
        else:
            res = []

        packet = dict(packet_type="S4",
                      res=res)
        res = self.push(packet)

        return res
开发者ID:jcsy521,项目名称:ydws,代码行数:30,代码来源:wspush_checker.py

示例2: pushS7

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def pushS7(tid, db, redis):
        """
        S7
        Information about basic info.

        res = []
        res.append(dict(tid=tid,
                        alias='jiajiajia',
                        icon_type=2,
                        owner_mobile='13011292217',
                        mannual_status=1,
                        ))
        """
        res = []
        terminal = QueryHelper.get_terminal_info(tid, db, redis)
        packet = dict(tid=tid,
                      biz_type=terminal.get('biz_type', 0),
                      alias=terminal['alias'],
                      icon_type=terminal['icon_type'],
                      owner_mobile=terminal['owner_mobile'],
                      mannual_status=terminal['mannual_status'])

        res.append(packet)

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

示例3: notify_to_parents

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def notify_to_parents(self, alias, location, mobile, region_id=None):
        """Push information to clinet through push.

        PUSH 1.0
        """
        flag = self.check_timestamp(int(location['timestamp']))
        if not flag: 
            return

        category = location.category
        dev_id = location.dev_id

        if not location['pbat']:
            terminal = QueryHelper.get_terminal_info(dev_id, self.db, self.redis) 
            location['pbat'] = terminal['pbat'] if terminal['pbat'] is not None else 0 

        if mobile:
            # 1: push to android
            android_push_list_key = get_android_push_list_key(mobile) 
            android_push_list = self.redis.getvalue(android_push_list_key) 
            if android_push_list: 
                for push_id in android_push_list: 
                    push_key = NotifyHelper.get_push_key(push_id, self.redis) 
                    NotifyHelper.push_to_android(category, dev_id, alias, location, push_id, push_key, region_id)
            # 2: push  to ios 
            ios_push_list_key = get_ios_push_list_key(mobile) 
            ios_push_list = self.redis.getvalue(ios_push_list_key) 
            if ios_push_list: 
                for ios_id in ios_push_list: 
                    ios_badge = NotifyHelper.get_iosbadge(ios_id, self.redis) 
                    NotifyHelper.push_to_ios(category, dev_id, alias, location, ios_id, ios_badge, region_id)
开发者ID:jcsy521,项目名称:ydws,代码行数:33,代码来源:packettask.py

示例4: pushS6

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def pushS6(tid, db, redis):
        """
        S6
        Information about basic info.

        res = []
        res.append(dict(tid=tid,
                        gps=8,
                        gsm=8,
                        pbat=8,
                        ))

        """
        res = []
        terminal = QueryHelper.get_terminal_info(tid, db, redis)
        packet = dict(tid=tid,
                      biz_type=terminal.get('biz_type', 0),
                      gps=terminal['gps'],
                      gsm=terminal['gsm'],
                      pbat=terminal['pbat'])
        res.append(packet)

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

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

示例5: update_terminal_dynamic_info

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
def update_terminal_dynamic_info(db, redis, location):
    """Update terminal's dynamic info in db and redis.
    Then inclues gps, gsm, pbat.
    """
    # db
    tid = location.dev_id
    fields = []

    # NOTE: only gps, gsm, pbat should be updated
    keys = ['gps', 'gsm', 'pbat']
    for key in keys:
        if location.get(key, None) is not None:
            fields.append(key + " = " + str(location[key]))
    set_clause = ','.join(fields)
    if set_clause:
        db.execute("UPDATE T_TERMINAL_INFO"
                   "  SET " + set_clause +
                   "  WHERE tid = %s",
                   tid)
    # redis
    terminal_info = QueryHelper.get_terminal_info(tid, db, redis)
    if terminal_info:
        terminal_info_key = get_terminal_info_key(tid)
        for key in terminal_info:
            value = location.get(key, None)
            if value is not None:
                terminal_info[key] = value
        redis.setvalue(terminal_info_key, terminal_info)
开发者ID:jcsy521,项目名称:ydws,代码行数:30,代码来源:public.py

示例6: pushS4

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def pushS4(tid, db, redis):
        """
        S4
        Information about online, offline.

        e.g.

        res = []
        res.append(dict(tid='tid1',
                        login_status=1))
        res.append(dict(tid='tid2',
                        login_status=2))

        """

        res = []

        t = QueryHelper.get_terminal_info(tid, db, redis)
        if t:
            res.append(dict(tid=tid,
                            biz_type=t.get('biz_type', 0),
                            login_status=t['login'] if t['login'] == 0 else 1))

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

示例7: update_terminal_info_ydwq

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
def update_terminal_info_ydwq(db, redis, t_info):
    """Update terminal's info in db and redis.
    """
    terminal_info_key = get_terminal_info_key(t_info['tid'])
    terminal_info = QueryHelper.get_terminal_info(t_info['tid'],
                                                  db, redis)

    # 1: db
    fields = []
    # gps, gsm, pbat, changed by position report
    keys = ['gps', 'gsm', 'pbat', 'login']
    for key in keys:
        value = t_info.get(key, None)
        if value is not None and value != terminal_info[key]:
            fields.append(key + " = " + str(t_info[key]))

    set_clause = ','.join(fields)
    if set_clause:
        db.execute("UPDATE T_TERMINAL_INFO"
                   "  SET " + set_clause +
                   "  WHERE tid = %s",
                   t_info['tid'])
    # 2: redis
    for key in terminal_info:
        value = t_info.get(key, None)
        if value is not None:
            terminal_info[key] = value
    redis.setvalue(terminal_info_key, terminal_info)

    return terminal_info
开发者ID:jcsy521,项目名称:ydws,代码行数:32,代码来源:public.py

示例8: update_terminal_info

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
def update_terminal_info(db, redis, t_info):
    """Update terminal's info in db and redis.

    :arg db: database instance 
    :arg redis: redis instance
    :arg terminal: dict, e.g.

        {
          'mobile':'',
          ...
        }

    NOTE: 
    Only those properties which are different from platform is needed to change.
    """
    tid = t_info['dev_id']
    terminal_info_key = get_terminal_info_key(tid)
    terminal_info = QueryHelper.get_terminal_info(tid,
                                                  db, redis)

    # 1: db
    set_clause_dct = []
    # gps, gsm, pbat, changed by position report
    keys = ['mobile', 'defend_status', 'login', 'keys_num', 'fob_status', 'mannual_status',
            'softversion', 'bt_mac', 'bt_name', 'dev_type']

    for key in keys:
        value = t_info.get(key, None)
        t_value = terminal_info.get(key, '')
        if value is not None and value != t_value:
            set_clause_dct.append(key + " = " + "'" + str(t_info[key]) + "'")

    if 'login_time' in t_info:
        set_clause_dct.append('login_time' + " = " + str(t_info['login_time']))
        login_time_key = get_login_time_key(tid)
        redis.setvalue(login_time_key, t_info['login_time'])

    set_clause = ','.join(set_clause_dct)
    if set_clause:
        sql_cmd = ("UPDATE T_TERMINAL_INFO "
                   "  SET " + set_clause +
                   "  WHERE tid = %s")
        db.execute(sql_cmd, tid)

    # 2: redis
    for key in terminal_info:
        value = t_info.get(key, None)
        if value is not None:
            terminal_info[key] = value
    redis.setvalue(terminal_info_key, terminal_info)

    # NOTE:wspush to client. terminal basic info
    WSPushHelper.pushS6(tid, db, redis)
    return terminal_info
开发者ID:jcsy521,项目名称:ydws,代码行数:56,代码来源:public.py

示例9: update_fob_info

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
def update_fob_info(db, redis, fobinfo):
    """Update fob's information.

    NOTE: deprecated.
    Tracker has not fob now.
    """
    terminal_info_key = get_terminal_info_key(fobinfo['dev_id'])
    terminal_info = QueryHelper.get_terminal_info(fobinfo['dev_id'],
                                                  db, redis)

    if int(fobinfo['operate']) == GATEWAY.FOB_OPERATE.ADD:
        db.execute("INSERT INTO T_FOB(tid, fobid)"
                   "  VALUES(%s, %s)"
                   "  ON DUPLICATE KEY"
                   "  UPDATE tid = VALUES(tid),"
                   "         fobid = VALUES(fobid)",
                   fobinfo['dev_id'], fobinfo['fobid'])
        fob_list = terminal_info['fob_list']
        if fob_list:
            fob_list.append(fobinfo['fobid'])
        else:
            fob_list = [fobinfo['fobid'], ]
        terminal_info['fob_list'] = list(set(fob_list))
        terminal_info['keys_num'] = len(terminal_info['fob_list'])
        db.execute("UPDATE T_TERMINAL_INFO"
                   "  SET keys_num = %s"
                   "  WHERE tid = %s",
                   terminal_info['keys_num'], fobinfo['dev_id'])
        redis.setvalue(terminal_info_key, terminal_info)
    elif int(fobinfo['operate']) == GATEWAY.FOB_OPERATE.REMOVE:
        db.execute("DELETE FROM T_FOB"
                   "  WHERE fobid = %s"
                   "    AND tid = %s",
                   fobinfo['fobid'], fobinfo['dev_id'])
        fob_list = terminal_info['fob_list']
        if fob_list:
            if fobinfo['fobid'] in fob_list:
                fob_list.remove(fobinfo['fobid'])
        else:
            fob_list = []
        terminal_info['fob_list'] = list(set(fob_list))
        terminal_info['keys_num'] = len(terminal_info['fob_list'])
        db.execute("UPDATE T_TERMINAL_INFO"
                   "  SET keys_num = %s"
                   "  WHERE tid = %s",
                   terminal_info['keys_num'], fobinfo['dev_id'])
        redis.setvalue(terminal_info_key, terminal_info)
    else:
        pass
开发者ID:jcsy521,项目名称:ydws,代码行数:51,代码来源:public.py

示例10: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
 def get(self):
     """Just just to a new page. 
     """
     # NOTE: The se_id should can be found in platform.
     se_id = self.get_argument("se_id", "")
     single_event = QueryHelper.get_single_event_by_se_id(se_id, self.db)
     terminal = QueryHelper.get_terminal_info(single_event["tid"], self.db, self.redis)
     self.render(
         "single_point.html",
         single_id=single_event["sid"],
         alias=terminal["alias"],
         tid=single_event.get("tid", ""),
         start_time=single_event.get("start_time"),
         end_time=single_event.get("end_time"),
     )
开发者ID:jcsy521,项目名称:ydws,代码行数:17,代码来源:corpsingle.py

示例11: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def get(self):
        """Get event info.
        """
        status = WXErrorCode.SUCCESS
        try:
            body = self.request.body
            openid = self.getopenid()
            user = self.db.get("SELECT uid, mobile "
                               "  FROM T_USER "
                               "  WHERE openid = %s", 
                               openid)

            if user is None:
                mobile = ''
                status = WXErrorCode.USER_BIND
                message=WXErrorCode.ERROR_MESSAGE[status]
                self.render('error.html',
                            status=status,
                            message=message)
                return
            else:
                mobile = user['mobile']
            try:
                res = self.db.query("SELECT tid FROM T_TERMINAL_INFO "
                                    "  WHERE owner_mobile = %s",
                                    mobile)
            except MySQLdb.Error as e:
                logging.exception("[WEIXIN]event search terminals failed, Exception:%s",
                              e.args)
            if not res:
                res = []
            for r in res:
                terminal = QueryHelper.get_terminal_info(r['tid'], self.db, self.redis)  
                r['alias'] = terminal['alias']
            self.render("event.html",  
                        openid=openid, 
                        res=res)

        except Exception as e:
            status = WXErrorCode.FAILED
            logging.exception("[WEIXIN] get event failed, Execptin:%s ",
                              e.args)
            self.render('error.html', 
                        status=status,
                        message=WXErrorCode.ERROR_MESSAGE[status])
开发者ID:jcsy521,项目名称:ydws,代码行数:47,代码来源:event.py

示例12: check_poweroff_timeout

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
 def check_poweroff_timeout(self):
     logging.info("[CELERY] checkertask check poweroff timeout started.")
     try:
         terminals = self.db.query("SELECT tpt.tid, tpt.sms_flag, tpt.timestamp"
                                   "  FROM T_POWEROFF_TIMEOUT as tpt, T_TERMINAL_INFO as tti"
                                   "  WHERE tti.tid = tpt.tid"
                                   "  AND tti.service_status = 1"
                                   "  AND tti.login = %s"
                                   "  AND tpt.sms_flag = %s"
                                   "  AND tpt.timestamp < %s",
                                   GATEWAY.TERMINAL_LOGIN.OFFLINE, GATEWAY.POWEROFF_TIMEOUT_SMS.UNSEND, (time.time() - 2*60*60))
         for terminal in terminals:
             terminal_info = QueryHelper.get_terminal_info(terminal.tid, self.db, self.redis)
             if int(terminal_info['pbat']) < 5:
                 user = QueryHelper.get_user_by_tid(terminal.tid, self.db)
                 sms = SMSCode.SMS_POWEROFF_TIMEOUT % terminal_info['alias'] 
                 SMSHelper.send(user.owner_mobile, sms)
                 self.update_sms_flag(terminal.tid)
                 logging.info("[CELERY] Send poweroff timeout sms to user:%s, tid:%s", user.owner_mobile, terminal.tid)
     except Exception as e:
         logging.exception("[CELERY] Check terminal poweroff timeout exception.")
开发者ID:jcsy521,项目名称:ydws,代码行数:23,代码来源:checkertask.py

示例13: pushS5

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def pushS5(tid, body, db, redis):
        """
        S5
        Information about alarm.

        res = []
        res.append(dict(tid=tid,
                        category=2, 
                        pbat=100,
                        type=1,
                        timestamp=1410939622,
                        longitude=419004000,
                        latitude=143676000,
                        clongitude=419004000,
                        clatitude=143676000,
                        name='test name',
                        speed=111,
                        degree=203,
                        gsm=0,
                        locate_error=100,
                        gps=25,
                        alias=111,
                        region_id=11
                    ))

        """
        res = []
        terminal = QueryHelper.get_terminal_info(tid, db, redis)
        body['biz_type'] = terminal.get('biz_type', 0)
        body['speed'] = int(round(body['speed']))

        res.append(body)

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

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

示例14: push_to_client

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]
    def push_to_client(self, location):
        """Push information to weixin and wspush.
        """
        #NOTE: use timestamp first. If it does not work, use gps_time.
        if location.get('timestamp',''):
            timestamp = location['timestamp']
        else:
            timestamp = location['gps_time']
        flag = self.check_timestamp(int(timestamp))
        if not flag: 
            return

        tid = location['dev_id']
        terminal = QueryHelper.get_terminal_info(tid, self.db, self.redis)
        body = dict(tid=tid,
                    category=location['category'], 
                    type=location['type'], 
                    timestamp=timestamp,
                    gps_time=location['gps_time'],
                    latitude=location.get('lat',0),
                    longitude=location.get('lon',0),
                    clatitude=location.get('cLat',0),
                    clongitude=location.get('cLon',0),
                    name=location['name'] if location.get('name',None) is not None else '',
                    degree=location.get('degree',0),
                    speed=location.get('speed',0),
                    locate_error=location.get('locate_error',0),
                    region_id=location.get('region_id',-1),
                    # for terminal
                    alias=terminal.get('alias'),
                    gps=terminal.get('gps'),
                    gsm=terminal.get('gsm'),
                    pbat=terminal.get('pbat'))

        WSPushHelper.pushS5(tid, body, self.db, self.redis)
        WeixinPushHelper.push(tid, body, self.db, self.redis)
开发者ID:jcsy521,项目名称:ydws,代码行数:38,代码来源:packettask.py

示例15: _on_finish

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_terminal_info [as 别名]

#.........这里部分代码省略.........
                        terminal_info_old, terminal_info_time = None, None
                    if terminal_info_old is not None:
                        if terminal_info_old != tids:
                            # logging.info("[UWEB] res_type=2, terminal_info changed, cid:%s", self.current_user.cid)
                            res_type = 2
                            self.redis.setvalue(terminal_info_key, (tids, current_time))
                        else:
                            if lastinfo_time < terminal_info_time:
                                # logging.info("[UWEB] res_type=2, terminal_info time changed, lastinfo_time:%s < terminal_info_time:%s, cid:%s",
                                # lastinfo_time, terminal_info_time,
                                # self.current_user.cid)
                                res_type = 2
                    else:
                        self.redis.setvalue(terminal_info_key, (tids, current_time))
                    _now_time = time.time()
                    if (_now_time - _start_time) > 5:
                        logging.info(
                            "[UWEB] Inclastinfo step1_group used time: %s > 5s, cid: %s, gid: %s",
                            _now_time - _start_time,
                            self.current_user.cid,
                            group.gid,
                        )
                    for tid in tids:
                        _now_time = time.time()
                        if (_now_time - _start_time) > 5:
                            logging.info(
                                "[UWEB] Inclastinfo step2 used time: %s > 5s, cid: %s",
                                _now_time - _start_time,
                                self.current_user.cid,
                            )

                        group["trackers"][tid] = {}
                        # 1: get terminal info
                        terminal = QueryHelper.get_terminal_info(tid, self.db, self.redis)
                        if terminal["login"] == GATEWAY.TERMINAL_LOGIN.SLEEP:
                            terminal["login"] = GATEWAY.TERMINAL_LOGIN.ONLINE

                        if terminal["login"] == GATEWAY.TERMINAL_LOGIN.ONLINE:
                            res["online"] += 1
                        else:
                            res["offline"] += 1

                        # 2: get location
                        location = QueryHelper.get_location_info(tid, self.db, self.redis)
                        if location and not (location.clatitude or location.clongitude):
                            location_key = get_location_key(str(tid))
                            locations = [location]
                            # NOTE: offset latlon
                            # locations = get_locations_with_clatlon(locations, self.db)
                            location = locations[0]
                            self.redis.setvalue(location_key, location, EVENTER.LOCATION_EXPIRY)

                        if location and location["name"] is None:
                            location["name"] = ""

                        if location and location["type"] == 1:  # cellid
                            location["locate_error"] = 500  # mile

                        acc_status_info = QueryHelper.get_acc_status_info_by_tid(
                            self.client_id, tid, self.db, self.redis
                        )
                        acc_message = acc_status_info["acc_message"]
                        op_status = acc_status_info["op_status"]

                        # 1: build the basic_info
                        basic_info = dict(
开发者ID:jcsy521,项目名称:ydws,代码行数:70,代码来源:inclastinfo.py


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