本文整理匯總了Python中jinja2.Template.desc方法的典型用法代碼示例。如果您正苦於以下問題:Python Template.desc方法的具體用法?Python Template.desc怎麽用?Python Template.desc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jinja2.Template
的用法示例。
在下文中一共展示了Template.desc方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sendcaserequest
# 需要導入模塊: from jinja2 import Template [as 別名]
# 或者: from jinja2.Template import desc [as 別名]
def sendcaserequest():
import time
session["result"] = {
"messages":[],
"successChecks":[],
"failedChecks":[]
}
info = {"result":True,"errorMsg":None,"ok":None,"success":0,"failed":0,"messages":None}
apiid = int(request.form.get("apiid"))
api = Api.query.filter_by(id=apiid).first()
name = request.form.get("name").strip()
desc = request.form.get("desc").strip()
script = request.form.get("script").strip()
purpose = request.form.get("purpose")
if purpose == "run":
actionParser = parseScript(script)
case = Template(case_template).render(
beforeAction = actionParser.beforeAction,
afterAction = actionParser.actions,
printActions = actionParser.printActions,
api = api,
checkActions = actionParser.checkActions,
purpose = purpose
)
try:
exec(case)
except Exception as e:
info["result"] = False
info["errorMsg"] = str(e)
info["messages"] = "\n".join([str(m) for m in session["result"]["messages"]]+session["result"]["failedChecks"]+session["result"]["successChecks"])
info["success"] = len(session["result"]["successChecks"])
info["failed"] = len(session["result"]["failedChecks"])
info["ok"] = False if session["result"]["failedChecks"] else True
elif purpose == "save":
case = ApiCase.query.filter_by(name=name).filter_by(userid=current_user.id).first()
if case:
info["result"] = False
info["errorMsg"] = "該名稱的用例已存在"
else:
try:
case = ApiCase(name,desc,script,current_user.id)
db.session.add(case)
db.session.commit()
api.apicases.append(case)
db.session.add(api)
db.session.commit()
except Exception as e:
info["result"] = False
info["errorMsg"] = "數據庫異常"
elif purpose == "edit":
print("edit case",name)
try:
caseid = int(request.form.get("caseid"))
case = ApiCase.query.filter_by(id=caseid).filter_by(userid=current_user.id).first()
if case:
case.name = name.strip()
case.desc = desc.strip()
case.content = script.strip()
db.session.add(case)
db.session.commit()
else:
info = {"result":False,"errorMsg":"該用例不存在或已被刪除"}
except Exception as e:
info["result"] = False
info["errorMsg"] = "數據庫異常"
else:
info = {"result":False,"errorMsg":"不支持的請求!"}
return jsonify(info)