def get(self, device_id, access_token, *args, **kwargs): name = device_id.split('@')[0] regHttpRpc = ServiceMgrCacher().get_connection(US_REGISTER,protocol=PT_HTTPS) result=get_users(regHttpRpc, access_token, [name]) device_id_ls = [ device_id ] user_info_ls = result['user_info_ls'][0] if user_info_ls['type'] != DEVICE_USER: roster = UserService().get_roster(name) roster_list = parse_ros_dic(roster, name=True) regHttpRpc = ServiceMgrCacher().get_connection(US_REGISTER,protocol=PT_HTTPS) result = get_users(regHttpRpc, access_token, roster_list) if 'user_info_ls' not in result: return [] user_info_ls = result['user_info_ls'] device_id_ls = [ user_info['jid'] for user_info in user_info_ls ] rpc_client = ServiceMgrCacher().get_connection(US_DEVICE_DA) return_ls = [] for device_id in device_id_ls: result_ls = query_task(rpc_client, device_id, '') for result in result_ls: param_time = result['time'] result['date'], result['time'] = param_time.split(' ') return_ls.extend(result_ls) return return_ls
def get(self, username, access_token, *args, **kwargs): roster = UserService().get_roster(username) roster_list = parse_ros_dic(roster, name=True) if not roster_list: return [] regHttpRpc = ServiceMgrCacher().get_connection(US_REGISTER, protocol=PT_HTTPS) result = get_users(regHttpRpc, access_token, roster_list) if result['result'] == error_code.ERROR_SUCCESS: return result['user_info_ls'] else: self.set_status(444,'error code:%s'%result['result']) return result