Update index.py

pull/620/head
Mr Chen 10 months ago
parent 6118c49335
commit e77b24a213
  1. 8
      plugins/openresty/index.py

@ -106,7 +106,7 @@ def getInitDTpl():
def getPidFile(): def getPidFile():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'pid\s*(.*);' rep = r'pid\s*(.*);'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -457,7 +457,7 @@ def getCfg():
# {"name": "client_body_buffer_size", "ps": "请求主体缓冲区"} # {"name": "client_body_buffer_size", "ps": "请求主体缓冲区"}
rdata = [] rdata = []
for i in cfg_args: for i in cfg_args:
rep = "(%s)\s+(\w+)" % i["name"] rep = r"(%s)\s+(\w+)" % i["name"]
k = re.search(rep, content) k = re.search(rep, content)
if not k: if not k:
return mw.returnJson(False, "获取 key {} 失败".format(k)) return mw.returnJson(False, "获取 key {} 失败".format(k))
@ -516,12 +516,12 @@ def setCfg():
# print(args) # print(args)
for k, v in args.items(): for k, v in args.items():
# print(k, v) # print(k, v)
rep = "%s\s+[^kKmMgG\;\n]+" % k rep = r"%s\s+[^kKmMgG\;\n]+" % k
if k == "worker_processes" or k == "gzip": if k == "worker_processes" or k == "gzip":
if not re.search("auto|on|off|\d+", v): if not re.search("auto|on|off|\d+", v):
return mw.returnJson(False, '参数值错误') return mw.returnJson(False, '参数值错误')
else: else:
if not re.search("\d+", v): if not re.search(r"\d+", v):
return mw.returnJson(False, '参数值错误,请输入数字整数') return mw.returnJson(False, '参数值错误,请输入数字整数')
if re.search(rep, content): if re.search(rep, content):

Loading…
Cancel
Save