代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
from flask import Flask,render_template,request,jsonify
import json,ast,requests
from developerRe.developerRe import get_Data,developerRe
from urllib.error import HTTPError
import urllib.request
import os,datetime
import xlrd,re
import setting
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
app.jinja_env.filters['zip'] = zip
TEMPLATES_AUTO_RELOAD = True
app.config.from_object(__name__)
# 设置Flask jsonify返回中文不转码
app.config['JSON_AS_ASCII'] = False
PIC_FOLDER = os.path.join(app.root_path, 'upload_pic')
# 配置数据库的地址
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:root@120.55.171.60:3306/robot'
# 跟踪数据库的修改 --> 不建议开启 未来的版本中会移除
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
dr_lda,dr_dictionary,dr_tasks,dr_dicts,dr_develpoers,dr_dict_task,dr_repoID_repoINFO=get_Data()
# 服务组合推荐模块
class Service_portfolio:
def __init__(self, KGfile, Profile):
# with open(KGfile, "r", encoding="utf-8") as f:
# file = f.read()
# self.KGdata = json.loads(KGfile)
self.KGdata = KGfile
# with open(Profile, "r", encoding="utf-8") as f:
# file = f.read()
# self.Prodata = json.loads(Profile)
self.Prodata = Profile
self.process_list = list(self.Prodata.keys())
self.attribute_list = [["内存资源", "内存", "资源"], ["网络带宽", "带宽"], ["响应时间", "响应", "时间"]]
# print(self.KGdata)
# print(self.Prodata)
def output(self, sp, topology, KGdata):
plan = []
for sp_ in sp:
plan_dict = {'name': sp_[2], 'value': sp_[1]}
data = []
for i, atom in enumerate(sp_[0].split('_')):
atom_dict = {"id": i, "name": atom, "desc": None, "value": [KGdata[atom]["内存资源"], KGdata[atom]["网络带宽"], KGdata[atom]["响应时间"]]}
data.append(atom_dict)
plan_dict["data"] = data
plan.append(plan_dict)
links = self.path(topology, sp[0][0].split('_'))
results = {"links": links, "plan": plan}
# print(results)
return results
def path(self, topology, name_list):
topology_c = {}
for topo, atomlist in topology.items():
topology_c[topo] = list(set(atomlist) & set(name_list))
# for i, name in enumerate(name_list):
topology_list = []
for i in range(len(topology_c)):
topology_list.append(topology_c[i])
links = []
for i, atom_list in enumerate(topology_list):
for atom in atom_list:
if i == len(topology_list) - 1:
break
for atom_next in topology_list[i+1]:
links.append([name_list.index(atom), name_list.index(atom_next)])
return links
def forward(self, candi_process, candi_attribute, candi_value):
graph = self.Prodata[candi_process]
# print(graph)
services = list(graph.keys())
atoms = []
atoms_ = []
KGdata = {}
for service in services:
for atom in self.KGdata[service].keys():
KGdata[atom] = self.KGdata[service][atom]
for service in services:
atoms.append(service)
atoms_.append(list(self.KGdata[service].keys()))
# print(atoms)
# print(atoms_)
atom_combine, atom_combine_ = [], []
topology = {}
for i, atom_list in enumerate(atoms_):
for atom in atom_list:
if graph[atoms[i]] in topology.keys():
topology[graph[atoms[i]]].append(atom)
else:
topology[graph[atoms[i]]] = [atom]
if i == 0:
atom_combine.append([atom])
else:
for atom_c in atom_combine:
tmp = atom_c + [atom]
atom_combine_.append(tmp)
if i != 0:
atom_combine = atom_combine_
atom_combine_ = []
# print(atom_combine)
# print(len(atom_combine))
# print(KGdata)
# print("====")
# print(topology)
# '内存资源'
atom_memory = {}
for atom_c in atom_combine:
memory = 0
for atom in atom_c:
memory += KGdata[atom]['内存资源']
# if memory in atom_memory.keys():
# atom_memory[memory].append(atom_c)
# else:
# atom_memory[memory] = [atom_c]
atom_memory['_'.join(atom_c)] = memory
atom_memory_sort = sorted(atom_memory.items(), key=lambda x: x[1])
# print(atom_memory_sort)
# '带宽'
atom_band = {}
for atom_c in atom_combine:
topology_c = {}
for topo, atomlist in topology.items():
topology_c[topo] = list(set(atomlist) & set(atom_c))
band = 0
for atomlist in topology_c.values():
band_tmp = 0
for atom in atomlist:
band_tmp += KGdata[atom]['网络带宽']
band = max(band, band_tmp)
# if band in atom_band.keys():
# atom_band[band].append(atom_c)
# else:
# atom_band[band] = [atom_c]
atom_band["_".join(atom_c)] = band
atom_band_sort = sorted(atom_band.items(), key=lambda x: x[1])
# print(atom_band_sort)
# '时延'
atom_delay = {}
for atom_c in atom_combine:
topology_c = {}
for topo, atomlist in topology.items():
topology_c[topo] = list(set(atomlist) & set(atom_c))
delay = 0
for atomlist in topology_c.values():
delay_tmp = 0
for atom in atomlist:
delay_tmp = max(KGdata[atom]['响应时间'], delay_tmp)
delay += delay_tmp
delay = round(delay, 2)
# if delay in atom_delay.keys():
# atom_delay[delay].append(atom_c)
# else:
# atom_delay[delay] = [atom_c]
atom_delay["_".join(atom_c)] = delay
atom_delay_sort = sorted(atom_delay.items(), key=lambda x:x[1])
# print(atom_delay_sort)
memory_list, band_list, delay_list = [], [], []
if candi_attribute == '内存资源':
atom_memory_min = atom_memory_sort[0]
if atom_memory_min[1] <= candi_value:
# 1 内存
# print(atom_memory_min[0], atom_memory_min[1])
# print(atom_band[atom_memory_min[0]], atom_delay[atom_memory_min[0]])
memory_list = [atom_memory_min[0], [atom_memory_min[1], atom_band[atom_memory_min[0]], atom_delay[atom_memory_min[0]]], "内存资源最优"]
# 2 带宽
for atom_band_min in atom_band_sort:
if atom_memory[atom_band_min[0]] <= candi_value:
# print(atom_band_min[0], atom_memory[atom_band_min[0]])
# print(atom_band_min[1], atom_delay[atom_band_min[0]])
band_list = [atom_band_min[0], [atom_memory[atom_band_min[0]], atom_band_min[1], atom_delay[atom_band_min[0]]], "网络带宽最优"]
break
# 3 时延
for atom_delay_min in atom_delay_sort:
if atom_memory[atom_delay_min[0]] <= candi_value:
# print(atom_delay_min[0], atom_memory[atom_delay_min[0]])
# print(atom_band[atom_delay_min[0]], atom_delay_min[1])
delay_list = [atom_delay_min[0], [atom_memory[atom_delay_min[0]], atom_band[atom_delay_min[0]], atom_delay_min[1]], "响应时间最优"]
break
results = self.output([memory_list, band_list, delay_list], topology, KGdata)
else:
results = {"message": "不存在符合内存资源要求的服务组合!"}
elif candi_attribute == '网络带宽':
atom_band_min = atom_band_sort[0]
if atom_band_min[1] <= candi_value:
# 1 带宽
# print(atom_band_min[0], atom_band_min[1])
# print(atom_memory[atom_band_min[0]], atom_delay[atom_band_min[0]])
band_list = [atom_band_min[0], [atom_memory[atom_band_min[0]], atom_band_min[1], atom_delay[atom_band_min[0]]], "网络带宽最优"]
# 2 内存
for atom_memory_min in atom_memory_sort:
if atom_band[atom_memory_min[0]] <= candi_value:
# print(atom_memory_min[0], atom_band[atom_memory_min[0]])
# print(atom_memory_min[1], atom_delay[atom_memory_min[0]])
memory_list = [atom_memory_min[0], [atom_memory_min[1], atom_band[atom_memory_min[0]], atom_delay[atom_memory_min[0]]], "内存资源最优"]
break
# 3 时延
for atom_delay_min in atom_delay_sort:
if atom_band[atom_delay_min[0]] <= candi_value:
# print(atom_delay_min[0], atom_memory[atom_delay_min[0]])
# print(atom_band[atom_delay_min[0]], atom_delay_min[1])
delay_list = [atom_delay_min[0], [atom_memory[atom_delay_min[0]], atom_band[atom_delay_min[0]], atom_delay_min[1]], "响应时间最优"]
break
results = self.output([band_list, memory_list, delay_list], topology, KGdata)
else:
results = {"message": "不存在符合网络带宽要求的服务组合!"}
elif candi_attribute == '响应时间':
atom_delay_min = atom_delay_sort[0]
if atom_delay_min[1] <= candi_value:
# 1 时延
# print(atom_delay_min[0], atom_delay_min[1])
# print(atom_band[atom_delay_min[0]], atom_memory[atom_delay_min[0]])
delay_list = [atom_delay_min[0], [atom_memory[atom_delay_min[0]], atom_band[atom_delay_min[0]], atom_delay_min[1]], "响应时间最优"]
# 2 带宽
for atom_band_min in atom_band_sort:
if atom_delay[atom_band_min[0]] <= candi_value:
# print(atom_band_min[0], atom_memory[atom_band_min[0]])
# print(atom_band_min[1], atom_delay[atom_band_min[0]])
band_list = [atom_band_min[0], [atom_memory[atom_band_min[0]], atom_band_min[1], atom_delay[atom_band_min[0]]], "网络带宽最优"]
break
# 3 内存
for atom_memory_min in atom_memory_sort:
if atom_delay[atom_memory_min[0]] <= candi_value:
# print(atom_memory_min[0], atom_delay[atom_memory_min[0]])
# print(atom_band[atom_memory_min[0]], atom_memory_min[1])
memory_list = [atom_memory_min[0], atom_memory_min[1], atom_band[atom_memory_min[0]], atom_delay[atom_memory_min[0]], "内存资源最优"]
break
results = self.output([delay_list, memory_list, band_list], topology, KGdata)
else:
results = {"message": "不存在符合响应时间要求的服务组合!"}
return results
############################################### PC 端 Cosine Robot 系统 #########################################################################
@app.route('/')
def pc_home():
# return render_template('pc/home.html')
return render_template('home.html')
@app.route('/index')
def index1():
return render_template('index.html')
@app.route('/home')
def home():
return render_template('home.html')
# 1.跳转到 API推荐的首页
@app.route('/apiSearch')
def apiSearch():
return render_template('api_Search.html')
# 1.1跳转到 API推荐的结果展示页
@app.route('/apiRecommend', methods={"POST", "GET"})
def apiRecommend():
if request.method == "POST":
requirement = request.form.get('requirement')
data = {
"requirement": requirement
}
url = "http://120.55.171.60:30424/apiRecommend?requirement="+requirement
try:
# requests = requests.post(url,data)
response1 = requests.get(url).text
data_json = ast.literal_eval(response1)
dataJson = data_json["data"]
data = {
"type": dataJson["type"],
"results": dataJson["results"],
"number": dataJson["number"]
}
except HTTPError as e:
print(e.read())
return render_template('api_recommend.html', data=data,requirement=requirement)
if request.method == "GET":
requirement = request.args.get('requirement')
data = {
"requirement": requirement
}
url = "http://120.55.171.60:30424/apiRecommend?requirement="+requirement
try:
# requests = requests.post(url,data)
response1 = requests.get(url).text
data_json = ast.literal_eval(response1)
dataJson = data_json["data"]
data = {
"type": dataJson["type"],
"results": dataJson["results"],
"number": dataJson["number"]
}
except HTTPError as e:
print(e.read())
return render_template('api_recommend.html', data=data,requirement=requirement)
# 2.跳转到代码推荐的首页
@app.route('/codeSearch')
def codeSearch():
return render_template('code_Search.html')
# 2.1 跳转到代码推荐的结果展示页
@app.route('/codeRecommend',methods={"POST","GET"})
def codeRecommend():
if request.method == "POST":
requirement= request.form['requirementCode']
data = {
"requirementCode": requirement
}
url = "http://120.55.171.60:31882/codeRecommend"
try:
response1 = requests.post(url, data).text
data_json = ast.literal_eval(response1)
requirement = data_json["requirement"]
datalist = data_json["datalist"]
dataCSDN_number = data_json["dataCSDN_number"]
dataNumber = data_json["dataNumber"]
urllist = data_json["urllist"]
except HTTPError as e:
print(e.read())
return render_template('code_Recommend.html',requirement=requirement,datalist=datalist,dataCSDN_number=dataCSDN_number,dataNumber=dataNumber,urllist=urllist)
# 跳转缺陷修复者推荐展示页
@app.route('/repairRecommend',methods={"POST","GET"})
def repairRecommend():
if request.method == 'POST':
requirement = request.form['requirement']
url = "http://120.55.171.60:30849/repairRecommend"
data = {
"requirement":requirement
}
try:
response1 = requests.post(url,data).text
# response1 = requests.get(url).text
data_json = ast.literal_eval(ast.literal_eval(response1))
size = data_json['size']
size = str(size)
list = data_json['list']
return render_template('repair_Recommend.html', bug_reporter_list=list,bug_reporter_size = size)
except HTTPError as e:
print(e.read())
return render_template('repair_Search.html')
return render_template('repair_Search.html')
# 缺陷修复者首页
@app.route('/repairSearch')
def repairSearch():
return render_template('repair_Search.html')
# 缺陷修复者首页 - 跳转手动填写缺陷报告
@app.route('/repairOutline')
def repairOutline():
return render_template('repair_outline.html')
# 接受文件上传
# 允许上传的文件类型
ALLOWED_EXTENSIONS = set(['txt','xls','csv'])
ALLOWED_EXTENSIONS_README = set(['txt'])
# 判断文件类型是否在允许的范围内
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
def allowed_file_README(filename):
return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS_README
# 缺陷报告上传解析
@app.route('/RepairfileUpload',methods={"POST","GET"})
def RepairfileUpload():
if request.method == "POST":
file = request.files['pic']
if file:
filename = file.filename
curr_time = datetime.datetime.now() #获取文件上传时的系统时间
curr_time_str = str(datetime.datetime.strftime(curr_time,'%Y%m%d%H%M%S') ) #处理文件上传时间
filename = curr_time_str+filename # 将处理之后的文件上传时间与文件名拼接在一起
# print(filename)
file.save(os.path.join(PIC_FOLDER, filename))
file_path = './upload_pic/'+filename
rdata = xlrd.open_workbook(file_path) # 打开文件名
sheet1 = rdata.sheet_by_index(0) # 获取到第一个sheet的信息
bug_id = str(int(sheet1.cell_value(2,0))) # bug id
bug_report_time= str(sheet1.cell_value(2,5)) # bug 提交时间
bug_reporter = str(sheet1.cell_value(2,1)) # bug 提交者
bug_title = str(sheet1.cell_value(2,2)) # bug 标题
bug_description = str(sheet1.cell_value(2,3)) # bug 描述
bug_comment = str(sheet1.cell_value(2,4)) # bug 评论
url = "http://f387o70426.goho.co/predict?bug_id=" + bug_id + "&bug_report_time=" + bug_report_time + "&bug_reporter=" + bug_reporter + "&bug_title=" + bug_title + "&bug_description=" + bug_description + "&bug_comment=" + bug_comment;
try:
response1 = requests.get(url)
# print(response1.json())
json_reaponse = response1.json()
# print(json_reaponse)
data = json_reaponse['data']
# data['class2score'] 返回推荐的修复者列表
# print(data)
bug_reporter_list = data['triager2info']
for bug_reporter in bug_reporter_list:
bug_reporter[2] = 0
# return render_template('repair_Recommend.html',bug_reporter_list=bug_reporter_list)
# bug_reporter_list = json.dumps(bug_reporter_list,ensure_ascii=False)
return str(bug_reporter_list)
except HTTPError as e:
print(e.read())
return render_template('repair_Search.html')
# ajax 异步问题解决
@app.route('/RepairfileSuccess',methods={"POST","GET"})
def RepairfileSuccess():
bug_reporter_list = request.args.get('bug_reporter_list')
bug_reporter_list = ast.literal_eval(bug_reporter_list)
bug_reporter_list = list(bug_reporter_list)
return render_template('repair_Recommend.html', bug_reporter_list=bug_reporter_list)
# 跳转建议反馈页面
@app.route('/feedback')
def feedback():
return render_template('feedback.html')
# APP 功能需求推荐首页
@app.route('/requirementSearch')
def requirementSearch():
return render_template('requirement_Search.html')
# APP 功能需求推荐结果展示页
@app.route('/requirementRecommend',methods={"POST","GET"})
def requirementRecommend():
global requirementRecommendJson
if request.method == 'GET':
# need_dict = {}
need = request.args.get('need')
# need_dict['requirement_description'] = need
# need_dict['flag'] = "1"
data = {
"requirement_description":need,
"flag":1
}
url = "http://www.cosinerobot.cn:31461/requirementRecommend"
data = {
"need":need
}
try:
response1 = requests.post(url,data).text
# response1 = requests.get(url).text
data_json = ast.literal_eval(response1)
apps_list = data_json['apps_list']
project_list = data_json['project_list']
requirementRecommendJson_list = data_json['requirementRecommendJson_list']
except HTTPError as e:
print(e.read())
# response1= urllib.request.urlopen(response1).read().decode("utf-8")
return render_template('requirement_Recommend.html',apps_list=apps_list,data_json=data_json,project_list=project_list,requirementRecommendJson_list=requirementRecommendJson_list)
# APP 功能需求推荐弹窗
@app.route('/requirementWrite')
def requirementWrite():
return render_template('requirement_Write.html')
# 服务推荐首页
@app.route('/serviceSearch')
def serviceSearch():
return render_template('service_Search.html')
# 服务推荐结果展示页
@app.route('/serviceRecommend',methods={"POST","GET"})
def serviceRecommend():
if request.method == "POST":
requirement = request.form.get('requirement')
url = "http://120.55.171.60:31852/serviceRecommend"
data = {"requirement": requirement}
try:
response1 = requests.post(url, data).text
data_json = ast.literal_eval(response1)
dataJson = data_json['data']
data = {
"type": dataJson['type'],
"results": dataJson['results'],
"results_fig1": dataJson['results_fig1'],
"results_fig2": dataJson['results_fig2'],
"number": dataJson['number']
}
except HTTPError as e:
print(e.read())
return render_template('service_Recommend.html', data=data)
# 测试工具集推荐首页
@app.route('/testToolsSearch')
def testToolsSearch():
return render_template('testtools_Search.html')
@app.route('/testTip',methods={"POST","GET"})
def testTip():
req = request.args.get("requirement")
url = "http://120.55.171.60:8100/robot_test/sut/getSutByLikeName/" + req
toolList = []
try:
# print(url)
r = requests.get(url)
response1 = r.text
# response_list = list(response1)
data_json = ast.literal_eval(response1)
# toolList = data_json['list']
except HTTPError as e:
print(e.read())
return json.dumps(data_json)
process_List = []
# 测试工具集推荐结果展示页 - 左侧模块展示部分 右侧调用 iframe 框
@app.route('/testtoolsRecommend',methods={"POST","GET"})
def testtoolsRecommend():
# 输入项目说明书
req = request.form.get('requirement')
url = "http://120.55.171.60:8100/robot_test/processes/getProcessesByLikeSutName/"+str(req)
processSize=0
processList=[]
try:
r = requests.get(url)
response1 = r.text
data_json = ast.literal_eval(response1)
processSize = data_json['size']
# 抽取出的是工具列表
processList = list(data_json['list'])
except HTTPError as e:
print(e.read())
global process_List
process_List = processList
return render_template('testtools_Recommend.html',processSize=processSize,processList=processList,requirement=req)
optimizationtool = {}
mo_del = {}
# 测试工具集推荐结果展示页 - 左侧测试模型的详情 - 第 1 步 测试模型信息的展示和编辑
@app.route('/testtoolsRecommend_model',methods={"POST","GET"})
def testtoolsRecommend_model():
# processList = request.args.get("processList")
global process_List
global optimization_tool
global mo_del
processList = process_List
name = request.args.get("name")
# processList = ast.literal_eval(processList)
model = processList[0]['model']['content']
optimizationtool = processList[0]['optimizationtool']
processList = processList[0]
optimization_tool = optimizationtool
mo_del = model
return render_template('testtools_Recommend_setmodel.html',model=model,processList=processList,name=name,optimizationtool=optimizationtool)
# 测试工具集推荐结果展示页 - 左侧测试模型的详情 - 第 2 步 推荐测试工具
@app.route('/testtoolsRecommend_toolsChoose',methods={"POST","GET"})
def testtoolsRecommend_toolsChoose():
global optimization_tool
global mo_del
optimizationtool = optimization_tool
model = mo_del
# optimizationtool = ast.literal_eval(optimizationtool)
# model = ast.literal_eval(model)
year = optimizationtool["year"]
author = optimizationtool['author']
name= optimizationtool["name"]
version = optimizationtool["version"]
content = optimizationtool['content']
url = optimizationtool["url"]
return render_template('testtools_Recommend_toolsChoose.html',model=model,optimizationtool=optimizationtool,year=year,author=author,name=name,version=version,content=content,url=url)
# 测试工具集推荐 - 第 2-1 步 智能工具比较
@app.route('/testtoolsCompare',methods={"POST","GET"})
def testtoolsCompare():
if request.method == 'POST':
need_dict = json.loads(request.form.get('data'))
url = "http://120.55.171.60:8100/service/generation/run"
headers = {'Content-Type': 'application/json'}
need_json = json.dumps(need_dict, ensure_ascii=False)
data = urllib.parse.quote_plus(need_json).encode("utf-8")
try:
response1 = urllib.request.Request(url, data=data, headers=headers)
except HTTPError as e:
print(e.read())
response1 = urllib.request.urlopen(response1).read().decode("utf-8")
data_json = ast.literal_eval(response1)
return data_json
# 测试工具集推荐结果展示页 - 左侧测试模型的详情 - 第 3 步 生成测试用例
@app.route('/testtoolsRecommend_generation')
def testtoolsRecommend_generation():
return render_template('testtools_Recommend_generation.html')
# 测试工具集推荐结果展示页 - 左侧测试模型的详情 - 第 2-2 步 图片生成
@app.route('/testtoolsRecommendCharts')
def testtoolsRecommendCharts():
alltimestr = request.args.get("alltime")
alltimestr = alltimestr.split(',')
alltime = []
for n in alltimestr:
alltime.append(int(n));
allsizestr = request.args.get("allsize")
allsizestr = allsizestr.split(',')
allsize = []
for n in allsizestr:
allsize.append(int(n));
toolnamesstr = request.args.get("toolnames")
toolnamesstr = toolnamesstr.split(',')
toolnames = []
for n in toolnamesstr:
toolnames.append(n);
return render_template('testtools_Recommend_charts.html',toolnames=toolnames,allsize=allsize,alltime=alltime)
# 算法推荐首页
@app.route('/algorithmSearch')
def algorithmSearch():
return render_template('algorithm_Search.html')
# 算法推荐结果展示页
@app.route('/algorithmRecommend',methods={"POST","GET"})
def algorithmRecommend():
if request.method == 'POST':
dataSelector = request.form["dataSelector"]
data = {
"dataSelector":dataSelector
}
url = "http://www.cosinerobot.cn:30626/algorithmRecommend"
try:
response1 = requests.post(url,data).text
# response1 = requests.get(url).text
data_json = ast.literal_eval(response1)
AlgoList = data_json['AlgoList']
dataset = data_json['dataset']
except HTTPError as e:
print(e.read())
return render_template('algorithm_Recommend.html',AlgoList=AlgoList,dataset=dataset)
# 开发者推荐首页
@app.route('/developerSearch')
def developerSearch():
return render_template('developer_Search.html')
# README文件上传
@app.route('/ReadMeFileUp',methods={"POST","GET"})
def ReadMeFileUp():
if request.method == "POST":
file = request.files['pic']
if file:
filename = file.filename
curr_time = datetime.datetime.now() # 获取文件上传时的系统时间
curr_time_str = str(datetime.datetime.strftime(curr_time, '%Y%m%d%H%M%S')) # 处理文件上传时间
filename = curr_time_str + filename # 将处理之后的文件上传时间与文件名拼接在一起
file_url = os.path.join(PIC_FOLDER, filename)
file.save(file_url)
return filename
# ajax 异步问题解决
@app.route('/READMEfileSuccess',methods={"POST","GET"})
def READMEfileSuccess():
filename = request.args.get('filename')
file_url = os.path.join(PIC_FOLDER, filename)
try:
with open(file_url, 'r') as f:
requirement = f.read()
f.close()
except HTTPError as e:
print(e.read())
pass
results = developerRe(requirement,dr_lda,dr_dictionary,dr_tasks,dr_dicts,dr_develpoers,dr_dict_task,dr_repoID_repoINFO)
data = {
"type": "search",
"results": results,
"number": len(results)
}
return render_template('developer_Recommend.html', data=data)
# 服务组合推荐首页
@app.route('/serviceCompositionSearch')
def serviceCompositionSearch():
return render_template('servicecomposition_Search.html')
# 服务组合推荐结果展示页
@app.route('/serviceCompositionRecommend',methods={"POST","GET"})
def serviceCompositionRecommend():
service_data = {
"搜索服务": {"搜索服务0": {"内存资源": 46, "网络带宽": 1624, "响应时间": 0.07}, "搜索服务1": {"内存资源": 28, "网络带宽": 1090, "响应时间": 0.26}},
"NLP基础服务": {"NLP基础服务0": {"内存资源": 79, "网络带宽": 2947, "响应时间": 0.04},
"NLP基础服务1": {"内存资源": 4, "网络带宽": 4204, "响应时间": 0.17},
"NLP基础服务2": {"内存资源": 94, "网络带宽": 4846, "响应时间": 0.26},
"NLP基础服务3": {"内存资源": 0, "网络带宽": 2678, "响应时间": 0.13}},
"知识图谱服务": {"知识图谱服务0": {"内存资源": 11, "网络带宽": 3626, "响应时间": 0.39},
"知识图谱服务1": {"内存资源": 55, "网络带宽": 1608, "响应时间": 0.34},
"知识图谱服务2": {"内存资源": 9, "网络带宽": 684, "响应时间": 0.1}},
"图像搜索": {"图像搜索0": {"内存资源": 99, "网络带宽": 635, "响应时间": 0.03}, "图像搜索1": {"内存资源": 40, "网络带宽": 3919, "响应时间": 0.24}},
"数据存储": {"数据存储0": {"内存资源": 55, "网络带宽": 288, "响应时间": 0.39}, "数据存储1": {"内存资源": 0, "网络带宽": 3394, "响应时间": 0.24},
"数据存储2": {"内存资源": 62, "网络带宽": 843, "响应时间": 0.04}, "数据存储3": {"内存资源": 61, "网络带宽": 4534, "响应时间": 0.05}},
"负载均衡": {"负载均衡0": {"内存资源": 24, "网络带宽": 3135, "响应时间": 0.05}},
"消息队列": {"消息队列0": {"内存资源": 7, "网络带宽": 1390, "响应时间": 0.38}},
"短信服务": {"短信服务0": {"内存资源": 14, "网络带宽": 1821, "响应时间": 0.03}, "短信服务1": {"内存资源": 62, "网络带宽": 1035, "响应时间": 0.01}},
"数据可视化服务": {"数据可视化服务0": {"内存资源": 62, "网络带宽": 4967, "响应时间": 0.43},
"数据可视化服务1": {"内存资源": 4, "网络带宽": 3237, "响应时间": 0.11}},
"实时计算服务": {"实时计算服务0": {"内存资源": 93, "网络带宽": 367, "响应时间": 0.28},
"实时计算服务1": {"内存资源": 89, "网络带宽": 1215, "响应时间": 0.3}},
"大数据计算与分析服务": {"大数据计算与分析服务0": {"内存资源": 65, "网络带宽": 4693, "响应时间": 0.38},
"大数据计算与分析服务1": {"内存资源": 11, "网络带宽": 3593, "响应时间": 0.42}},
"结算服务": {"结算服务0": {"内存资源": 60, "网络带宽": 1425, "响应时间": 0.07}, "结算服务1": {"内存资源": 61, "网络带宽": 4087, "响应时间": 0.39}},
"容器服务": {"容器服务0": {"内存资源": 3, "网络带宽": 2484, "响应时间": 0.04}, "容器服务1": {"内存资源": 10, "网络带宽": 1479, "响应时间": 0.27}},
"服务网格": {"服务网格0": {"内存资源": 65, "网络带宽": 4572, "响应时间": 0.21}, "服务网格1": {"内存资源": 7, "网络带宽": 4920, "响应时间": 0.28}},
"弹性计算服务": {"弹性计算服务0": {"内存资源": 27, "网络带宽": 192, "响应时间": 0.43},
"弹性计算服务1": {"内存资源": 90, "网络带宽": 1432, "响应时间": 0.19}},
"图像存储": {"图像存储0": {"内存资源": 84, "网络带宽": 660, "响应时间": 0.27}, "图像存储1": {"内存资源": 67, "网络带宽": 1688, "响应时间": 0.11}},
"文件存储": {"文件存储0": {"内存资源": 19, "网络带宽": 2298, "响应时间": 0.31}, "文件存储1": {"内存资源": 55, "网络带宽": 3410, "响应时间": 0.49}},
"云解析服务": {"云解析服务0": {"内存资源": 88, "网络带宽": 846, "响应时间": 0.06},
"云解析服务1": {"内存资源": 45, "网络带宽": 1205, "响应时间": 0.07}},
"反向代理": {"反向代理0": {"内存资源": 3, "网络带宽": 1390, "响应时间": 0.42}, "反向代理1": {"内存资源": 9, "网络带宽": 2317, "响应时间": 0.21}},
"监控服务": {"监控服务0": {"内存资源": 73, "网络带宽": 2395, "响应时间": 0.42}, "监控服务1": {"内存资源": 54, "网络带宽": 3639, "响应时间": 0.05}},
"消息中心": {"消息中心0": {"内存资源": 99, "网络带宽": 2009, "响应时间": 0.19}, "消息中心1": {"内存资源": 72, "网络带宽": 2327, "响应时间": 0.36}},
"即时通讯服务": {"即时通讯服务0": {"内存资源": 93, "网络带宽": 987, "响应时间": 0.49},
"即时通讯服务1": {"内存资源": 55, "网络带宽": 4459, "响应时间": 0.29}},
"加密服务": {"加密服务0": {"内存资源": 98, "网络带宽": 4599, "响应时间": 0.32}, "加密服务1": {"内存资源": 97, "网络带宽": 89, "响应时间": 0.05}}}
module_data = {
"用户中心": {
"搜索服务": 0,
"数据存储": 1,
"图像存储": 1,
"大数据计算与分析服务": 2
},
"知识中心": {
"搜索服务": 0,
"NLP基础服务": 1,
"文件存储": 2,
"数据存储": 2,
"大数据计算与分析服务": 3
},
"云开发模块": {
"负载均衡服务": 0,
"弹性计算服务": 1,
"容器服务": 2,
"服务网格": 3
},
"持久化模块": {
"数据存储": 0,
"图像存储": 1,
"文件存储": 2
},
"事件中心": {
"负载均衡": 0,
"消息队列": 1,
"加密服务": 2
},
"智能对话模块": {
"NLP基础服务": 0,
"知识图谱服务": 1,
"大数据计算与分析服务": 2,
"即时通讯服务": 3
},
"订单结算模块": {
"消息队列": 0,
"结算服务": 1,
"数据存储": 2,
"短信服务": 3
},
"监控模块": {
"监控服务": 0,
"负载均衡": 1,
"消息队列": 2,
"短信服务": 4
},
"日志模块": {
"负载均衡": 0,
"消息队列": 1,
"数据存储": 2
},
"API网关路由模块": {
"云解析服务": 0,
"负载均衡": 1,
"反向代理": 2
},
"数据中心": {
"大数据计算与分析服务": 0,
"数据存储": 1,
"实时计算服务": 2,
"数据可视化服务": 3
}
}
sp = Service_portfolio(service_data, module_data)
fieldSelector = request.args.get("fieldSelector")
dataSelector = request.args.get("dataSelector")
value_input = request.args.get("value_input")
if dataSelector == "响应时间":
value_input = float(value_input)
data = sp.forward(str(fieldSelector),str(dataSelector),int(value_input))
return render_template('servicecomposition_Recommend.html',data=data)
# 根据项目说明书,解析出项目的功能
def getFunction(requirement_description):
# 输入项目说明书
need_dict={}
need_dict['requirement_description'] = requirement_description
url = "http://120.55.171.60:8234/requirement"
headers = {'Content-Type': 'application/json'}
# 解析出项目说明书
need_json = json.dumps(need_dict, ensure_ascii=False)
data = urllib.parse.quote_plus(need_json).encode("utf-8")
try:
response1 = urllib.request.Request(url, data=data, headers=headers)
except HTTPError as e:
print(e.read())
response1= urllib.request.urlopen(response1).read().decode("utf-8")
response_list = list(response1)
data_json = ast.literal_eval(response1)
# 抽取出的是项目的功能短语对于的参考项目
project_list = data_json[0]
# 抽取出的是项目的功能短语
function_list = data_json[1]
return function_list
if __name__ == '__main__':
app.run(host="0.0.0.0",port=9000,threaded=True)
#ssl_context=('6531915_www.cosinerobot.cn.pem','6531915_www.cosinerobot.cn.key'))
# app.run(host="127.0.0.1",port=8080,threaded=True)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。