Beispiel #1
0
    def web_unpick(self, data_ls):
        """
        web 反序列化
        :param data_ls:
        :return:
        """
        unpick_ls = copy.deepcopy(data_ls)

        v_unpick_data_ls = []
        for data_dic in unpick_ls:
            try:
                data_dic['port'] = ujson.loads(
                    data_dic['port']) if data_dic['port'] else {}
                data_dic['params'] = ujson.loads(
                    data_dic['params']) if data_dic['params'] else {}

                if not data_dic['id']\
                        or not data_dic['service_group']\
                        or not IP_REGEX.match(data_dic['ip']) if data_dic['ip'] else False:
                    logger.warn("TPServiceMgr::web_unpick invalid params:%s" %
                                data_dic)
                    continue
            except:
                logger.warn("TPServiceMgr::web_unpick invalid params:%s %s" %
                            (data_dic, traceback.format_exc()))
                raise

            v_unpick_data_ls.append(data_dic)
        return v_unpick_data_ls
Beispiel #2
0
    def web_unpick(self, data_ls):
        """
        web 反序列化
        :param data_ls:
        :return:
        """
        unpick_ls = copy.deepcopy(data_ls)

        v_unpick_data_ls = []
        for data_dic in unpick_ls:
            try:
                data_dic['port'] = ujson.loads(data_dic['port']) if data_dic['port'] else {}
                data_dic['params'] = ujson.loads(data_dic['params']) if data_dic['params'] else {}

                if not data_dic['id']\
                        or not data_dic['service_group']\
                        or not IP_REGEX.match(data_dic['ip']) if data_dic['ip'] else False:
                    logger.warn("TPServiceMgr::web_unpick invalid params:%s" % data_dic)
                    continue
            except:
                logger.warn("TPServiceMgr::web_unpick invalid params:%s %s" % (data_dic, traceback.format_exc()))
                raise

            v_unpick_data_ls.append(data_dic)
        return v_unpick_data_ls
Beispiel #3
0
 def is_jid(jid):
     """
     判断是否是JID
     :param jid: 字符串
     :return:True or False
     """
     user_name, openfire_ip = jid.split("@")
     return IP_REGEX.search(openfire_ip) if user_name else False
Beispiel #4
0
 def is_jid(jid):
     """
     判断是否是JID
     :param jid: 字符串
     :return:True or False
     """
     user_name, openfire_ip = jid.split("@")
     return IP_REGEX.search(openfire_ip) if user_name else False
Beispiel #5
0
    def web_unpick(self, data_ls):
        """
        web 反序列化
        :param data_ls:
        :return:
        """
        unpick_ls = copy.deepcopy(data_ls)

        now_time = datetime_to_string(datetime.datetime.now())
        v_data_ls = []
        for data_dic in unpick_ls:
            if not IP_REGEX.match(data_dic['ip']):
                logger.warn("GrantMachineMgr::web_unpick invalid params:%s" % data_dic)
                continue

            if not TIME_STR_REGEX.match(data_dic['create_time']):
                data_dic['create_time'] = now_time

            if not data_dic['os'] in VALIDATE_OS:
                data_dic['os'] = OS_WINDOWS

            v_data_ls.append(data_dic)
        return v_data_ls