from django.http import HttpResponse from server.lib.qr_context import get_context # @csrf_exempt def updatax(request): print("ok") if request.method == "GET": print("ok") file = request.FILES.get('file') if file: filename = str(file) with open('./nsfocus/media/xmind/'+filename, 'wb+') as destination: for chunk in file.chunks(): destination.write(chunk) with open('./nsfocus/media/xmind/'+filename, 'rb') as f: content = f.read() # content = BytesIO(content) # xmind_dict = xmind_to_dict(content) # sheet = xmind_dict[0] # # {'title': '防火墙', # # 'topics': # # [{'title': '首页(信息可视化)', # # 'topics': [{'title': 'CPU'}, {'title': '内存'}, {'title': '趋势图'}]}, # # {'title': 'Dos防护', 'topics': [{'title': 'Flood防护:根据检测阈值,检测周期,复位时间,自动保护,保护时间,流量显示进行防护。'}, {'title': 'Port防护'}, {'title': 'PINGSweep防护'}, {'title': 'ARPpoof防护'}]}]} # print("ok") # root_topic = sheet['topic'] # root_one = root_topic['title'] # root_two = [] # root_three = [] # str1 = " " # str2 = " " # str3 = " " # str4 = " " # num = 1 # # for data in root_topic['topics']: # root_two.append(data['title']) # str1 = str(num) + "." + data['title'] # str2 = str2 + str1 # num = num + 1 # num2 = 1 # for info in data['topics']: # root_three.append(info['title']) # str3 = str(num2) + "." + info['title'] # str4 = str4 + str3 # num2 = num2 + 1 # xmind_title = str2 # xmind_xmind_root = str4 # prompt1 = "我是一个软件测试工程师,现在我要测试一个" + root_one + "产品,首先我有的模块是:" + str2 + "请针对这两个模块结合产品" + root_one + "给我提供一点测试思路,内容尽量详细。" # gpt_little = chatgpt(prompt1) # prompt2 = "我是一个软件测试工程师,产品" + root_one + "的模块:" + str2 + "的详细" + "细节信息为:" + str4 + "请提供我更详细的测试思路" # gpt_big = chatgpt(prompt2) # prompt3 = "我是一个软件测试工程师,产品是" + root_one + "模块为:" + str2 + "模块的详细内容为:" + str4 + "请给我更好的建议和一些发散性的测试想法。" # gpt_more = chatgpt(prompt3) # prompt4 = "我是一个软件测试工程师,产品是" + root_one + "结合刚才你对我的测试内容的意见和思路:" + gpt_little + gpt_big + gpt_more + "请精简总结和点评上述内容。" # gpt_all = chatgpt(prompt4) # # last = "我是一个软件测试工程师,产品是" + root_one + "结合刚才你对我的测试内容的意见和思路:" + gpt_little + gpt_big + gpt_more + # # "请利用等价类、边界值、场景法等方法设计用例,输出字段要求有前置条件、序号、测试标题、测试数据、测试步骤、预期结果等;请给出x条用例,测试步骤在y条以上。" # models.Xmind.objects.create(filename=filename,xmind_title=xmind_title,xmind_root=xmind_xmind_root,gpt_little=gpt_little # ,gpt_big=gpt_big,gpt_more=gpt_more,gpt_all=gpt_all) # return HttpResponse(xmind_dict) return HttpResponse('Invalid request method')