def RunTest(): #print(help(py_client)) if not py_client.Init(): print("init fail") return #连接文件服务器 conn_id = py_client.Connect("tcp:127.0.0.1:10030", True) print("conn_id=%d" % conn_id) request = { "src_type": 65001, "src_id": 1, "dest_type": 4, "dest_id": 0, "msg_id": 2, "version": 0, "data": {} } req_str = json.dumps(request) #print('req:%s' % req_str) resp_str = py_client.Send(conn_id, req_str) #print("resp:%s" % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('register fail,error_msg=%s' % resp_json['function_return']) return if 0 != resp_json['error_code']: print('register fail,error_code=%d' % resp_json['error_code']) return account = "lljzfly" password = "******" #文件 print("------test DownloadFileGetInfoReq") request = { "src_type": 65001, "src_id": 1, "dest_type": 4, "dest_id": 0, "msg_id": 1008, "version": 0, "data": { "account": account, "password": password, "file_name": "thinking", "file_lnd_name": "", } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) print('resp:%s' % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) resp_json_data = json.loads(resp_json['data']) #文件 print("------test DownloadFileGetInfoReq") request = { "src_type": 65001, "src_id": 1, "dest_type": 4, "dest_id": 0, "msg_id": 1008, "version": 0, "data": { "account": account, "password": password, "file_lnd_name": resp_json_data['file_lnd_name'], } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) print('resp:%s' % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) py_client.Disconnect(conn_id) py_client.Stop() py_client.Wait()
def RunTest(): #print(help(py_client)) if not py_client.Init(): print("init fail") return #连接账号服务器 conn_id=py_client.Connect("tcp:127.0.0.1:10020",True) print("conn_id=%d" % conn_id) request = { "src_type":65001, "src_id":1, "dest_type":4, "dest_id":0, "msg_id":2, "version":0, "data":{} } req_str=json.dumps(request) #print('req:%s' % req_str) resp_str=py_client.Send(conn_id,req_str) #print("resp:%s" % resp_str) resp_json=json.loads(resp_str) if resp_json['function_return']: print('register fail,error_msg=%s' % resp_json['function_return']) return if 0!=resp_json['error_code']: print('register fail,error_code=%d' % resp_json['error_code']) return #回显 ''' request = { "src_type":65001, "src_id":1, "dest_type":3, "dest_id":0, "msg_id":0, "version":0, "data":{ "message":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld" } } req_str=json.dumps(request) start=datetime.datetime.now() n=0 while n < 10000: n+=1 resp_str=py_client.Send(conn_id,req_str) resp_json=json.loads(resp_str) #print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s, n=%d' % (resp_json['function_return'],n)) break; if 0!=resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) break end=datetime.datetime.now() print("time=%d" % (end-start).seconds) return ''' #注册账号 print("------test Register") password="******" request = { "src_type":65001, "src_id":1, "dest_type":4, "dest_id":0, "msg_id":1000, "version":0, "data":{ "account":"", "password":password } } account="lljzfly_%08d" % time.time() request['data']['account']=account req_str=json.dumps(request) print("req_str:%s" % req_str) resp_str=py_client.Send(conn_id,req_str) print('resp:%s' % resp_str) resp_json=json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0!=resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) py_client.Disconnect(conn_id) #连接文件服务器 conn_id=py_client.Connect("tcp:127.0.0.1:10030",True) print("conn_id=%d" % conn_id) request = { "src_type":65001, "src_id":1, "dest_type":4, "dest_id":0, "msg_id":2, "version":0, "data":{} } req_str=json.dumps(request) #print('req:%s' % req_str) resp_str=py_client.Send(conn_id,req_str) #print("resp:%s" % resp_str) resp_json=json.loads(resp_str) if resp_json['function_return']: print('register fail,error_msg=%s' % resp_json['function_return']) return if 0!=resp_json['error_code']: print('register fail,error_code=%d' % resp_json['error_code']) return #文件服务器回显 ''' request = { "src_type":65001, "src_id":1, "dest_type":3, "dest_id":0, "msg_id":0, "version":0, "data":{ "message":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld" } } req_str=json.dumps(request) start=datetime.datetime.now() n=0 while n < 10000: n+=1 resp_str=py_client.Send(conn_id,req_str) resp_json=json.loads(resp_str) #print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s, n=%d' % (resp_json['function_return'],n)) break; if 0!=resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) break end=datetime.datetime.now() print("time=%d" % (end-start).seconds) return ''' #创建文件夹 print("------test CreateFolderReq") request = { "src_type":65001, "src_id":1, "dest_type":4, "dest_id":0, "msg_id":1000, "version":0, "data":{ "account":account, "password":password, "folder_name":"/math" } } req_str=json.dumps(request) print("req_str:%s" % req_str) resp_str=py_client.Send(conn_id,req_str) print('resp:%s' % resp_str) resp_json=json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0!=resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) #修改文件夹名称 print("------test ModifyPropertyReq") request = { "src_type":65001, "src_id":1, "dest_type":4, "dest_id":0, "msg_id":1002, "version":0, "data":{ "account":account, "password":password, "type":0, "src_name":"/math" "folder_name":"ecnomic" } } req_str=json.dumps(request) print("req_str:%s" % req_str) resp_str=py_client.Send(conn_id,req_str) print('resp:%s' % resp_str) resp_json=json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0!=resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) py_client.Disconnect(conn_id) py_client.Stop() py_client.Wait()
def RunTest(): #print(help(py_client)) if not py_client.Init(): print("init fail") return #连接 conn_id = py_client.Connect("tcp:127.0.0.1:10020", True) print("conn_id=%d" % conn_id) request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 2, "version": 0, "data": {} } req_str = json.dumps(request) #print('req:%s' % req_str) resp_str = py_client.Send(conn_id, req_str) #print("resp:%s" % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('register fail,error_msg=%s' % resp_json['function_return']) return if 0 != resp_json['error_code']: print('register fail,error_code=%d' % resp_json['error_code']) return #回显 ''' request = { "src_type":65001, "src_id":1, "dest_type":3, "dest_id":0, "msg_id":0, "version":0, "data":{ "message":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld" } } req_str=json.dumps(request) start=datetime.datetime.now() n=0 while n < 10000: n+=1 resp_str=py_client.Send(conn_id,req_str) resp_json=json.loads(resp_str) #print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s, n=%d' % (resp_json['function_return'],n)) break; if 0!=resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) break end=datetime.datetime.now() print("time=%d" % (end-start).seconds) ''' #注册 print("------test Register") password = "******" request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1000, "version": 0, "data": { "account": "", "password": password } } account = "yangjinbin_%08d" % time.time() request['data']['account'] = account req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) print('resp:%s' % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) #设置账号信息 print("------test SetAccountInfoReq") request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1002, "version": 0, "data": { "account": account, "img_url": "http://www.lljz.com/img_server/123.png", "home_page": "http://www.lljz.com/" } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) resp_json = json.loads(resp_str) print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) #修改登陆密码 print("------test ModifyLoginPasswordReq") new_password = "******" request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1004, "version": 0, "data": { "account": account, "old_password": password, "new_password": "******" } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) resp_json = json.loads(resp_str) print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) #登陆 print("------test LoginReq") print("++++++wrong password") request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1006, "version": 0, "data": { "account": account, "password": "******" } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) resp_json = json.loads(resp_str) print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) print("++++++right password") request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1006, "version": 0, "data": { "account": account, "password": new_password } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) resp_json = json.loads(resp_str) print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) #登出 print("------test LogoutReq") print("++++++wrong password") request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1008, "version": 0, "data": { "account": account, "password": new_password } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) resp_json = json.loads(resp_str) print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) py_client.Stop() py_client.Wait()
def RunTest(): #print(help(py_client)) if not py_client.Init(): print("init fail") return #连接 conn_id = py_client.Connect("tcp:127.0.0.1:10020", True) print("conn_id=%d" % conn_id) request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 2, "version": 0, "data": {} } req_str = json.dumps(request) #print('req:%s' % req_str) resp_str = py_client.Send(conn_id, req_str) #print("resp:%s" % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('register fail,error_msg=%s' % resp_json['function_return']) return if 0 != resp_json['error_code']: print('register fail,error_code=%d' % resp_json['error_code']) return #注册 print("------test Register") account = "lljzfly" password = "******" request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1000, "version": 0, "data": { "account": account, "password": password } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) print('resp:%s' % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) #设置账号信息 print("------test SetAccountInfoReq") request = { "src_type": 65001, "src_id": 1, "dest_type": 3, "dest_id": 0, "msg_id": 1002, "version": 0, "data": { "account": account, "img_url": "http://www.lljz.com/img_server/123.png", "home_page": "http://www.lljz.com/" } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) resp_json = json.loads(resp_str) print('resp:%s' % resp_json) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) py_client.Disconnect(conn_id) py_client.Stop() py_client.Wait()
def RunTest(): #print(help(py_client)) if not py_client.Init(): print("init fail") return #连接文件服务器 conn_id = py_client.Connect("tcp:127.0.0.1:10030", True) print("conn_id=%d" % conn_id) request = { "src_type": 65001, "src_id": 1, "dest_type": 4, "dest_id": 0, "msg_id": 2, "version": 0, "data": {} } req_str = json.dumps(request) #print('req:%s' % req_str) resp_str = py_client.Send(conn_id, req_str) #print("resp:%s" % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('register fail,error_msg=%s' % resp_json['function_return']) return if 0 != resp_json['error_code']: print('register fail,error_code=%d' % resp_json['error_code']) return account = "lljzfly" password = "******" #上传文件 print("------test UploadFileReq") request = { "src_type": 65001, "src_id": 1, "dest_type": 4, "dest_id": 0, "msg_id": 1004, "version": 0, "data": { "account": account, "password": password, "file_name": "my_thinking", "seq_no": 1, "length": 41, "data": "follow nature,not force,that is my heart." } } req_str = json.dumps(request) print("req_str:%s" % req_str) resp_str = py_client.Send(conn_id, req_str) print('resp:%s' % resp_str) resp_json = json.loads(resp_str) if resp_json['function_return']: print('request fail,error_msg=%s' % (resp_json['function_return'])) if 0 != resp_json['error_code']: print('request fail,error_code=%d' % resp_json['error_code']) py_client.Disconnect(conn_id) py_client.Stop() py_client.Wait()