def get(self, access_token, user_name_ls=None): """ http get 请求 :param access_token:访问码 :param user_name_ls: 用户名列表 :return:[user_dic,,,,] """ user_name_ls = ujson.loads(user_name_ls) if not access_token\ or not user_name_ls: return {'result': error_code.ERROR_PARAMS_ERROR} if not TokenMgr.check_expire_access_token(access_token): return {'result': error_code.ERROR_ACCESS_TOKEN_ERROR} result = {'result': error_code.ERROR_SUCCESS} connects = ServiceMgrCacher().get_connections(US_REGISTER_DA, RT_HASH_RING, user_name_ls) for connect, name_ls in connects.items(): params = {"user_name_ls": name_ls} user_info_ls = user_select(connect, **params) [user_dic.__setitem__('device_type', get_device_type(ParamCacher().sm_rpc, user_dic['device_type'])) for user_dic in user_info_ls if user_dic['device_type']] result.setdefault('user_info_ls', []).extend(user_info_ls) return result
def get(self, verify_code, user_name, password, type, device_type="", des="", param_sign=None, proxy_sign=None): """ http get 请求 :param verify_code: 验证码 :param user_name: 用户名 :param password: 密码 :param type: 用户类型 :param device_type: 设备类型,对应设备用户 :param des: 描述 :param param_sign:程序签名 :param proxy_sign: 代理签名 :return: {} """ if not user_name\ or not password\ or not type\ or not int(type) in enum.USER_TYPE_LS\ or not device_type in get_device_type(ParamCacher().sm_rpc).keys() if int(type) == enum.DEVICE_USER else False: return {'result': error_code.ERROR_PARAMS_ERROR} # 如果有param_sign,可使用验证param_sign越过验证码 is_privilege = Signer().check_sign(param_sign, verify_code, user_name, password, type, des) \ if param_sign \ else False # 不使用验证码判斷 if type and int(type) in enum.NOT_VERIFY_CODE_USER_LS: is_privilege = True if not is_privilege: if not cookie.check_cookie(self, "register_verify_code", verify_code): logger.error("RegisterHandle check_cookie failed!!!, verify_code:%s\n,param_sign:%s\n, HTTP_SGIN:%s" % (verify_code, param_sign, HTTP_SIGN)) return {'result': error_code.ERROR_VERIFY_CODE_ERROR} rgst_da_tcp = ServiceMgrCacher().get_connection(US_REGISTER_DA, RT_HASH_RING, [user_name]) if get_user_info(rgst_da_tcp, user_name): return {'result': error_code.ERROR_USER_NAME_EXIST} new_jid_dic = UserService().new_jid(user_name, password) params = {"user_name": user_name, "password": password, "des": des, "jid": new_jid_dic['jid'], "jid_pwd": new_jid_dic['password'], "type": type, "device_type": device_type} result = rgst_da_tcp.fetch_async("user_insert", ujson.dumps(params)) if ArgumentParser().args.use_sign: result['sign'] = proxy_sign if proxy_sign else HTTP_SIGN return result
def init(self, args): """ init :param args: :return: """ device_dict = get_device_type(ParamCacher().sm_rpc) assert device_dict Cache.loads(device_dict) from utils.openfire.user_service import UserService UserService(args.openfire_ip, args.openfire_port) logger.info("get device type control msg:%s" % device_dict)
#!/usr/bin/python2.7 # coding=utf-8 """ Created on 2015-8-26 @author: Jay """ from interfaces.service_mgr.tcp_rpc import get_device_type from utils.service_control.cacher import ParamCacher import random device_type_ls = get_device_type(ParamCacher().sm_rpc).keys() assert device_type_ls def choice_device_type(): return random.choice(device_type_ls)
def pull(self): """ 从sm获取设备类型数据 :return: """ self.__device_type_dic = get_device_type(ParamCacher().sm_rpc)