mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:29:26 +08:00
py3升级.1
This commit is contained in:
@@ -272,7 +272,8 @@ done
|
||||
data['dirs'].append(tmp)
|
||||
else:
|
||||
data['files'].append(tmp)
|
||||
except:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
continue
|
||||
return mw.returnJson(True, 'OK', data)
|
||||
|
||||
@@ -451,7 +452,7 @@ done
|
||||
else:
|
||||
filesx.append(filename)
|
||||
|
||||
print filesx
|
||||
# print(filesx)
|
||||
|
||||
for fn in filesx:
|
||||
if fn == '.':
|
||||
@@ -795,6 +796,8 @@ done
|
||||
pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8')
|
||||
data['PAGE'] = pageObj[0]
|
||||
|
||||
print('....eeee.11..')
|
||||
|
||||
i = 0
|
||||
n = 0
|
||||
for filename in os.listdir(path):
|
||||
@@ -834,7 +837,8 @@ done
|
||||
filenames.append(filename + ';' + size + ';' +
|
||||
mtime + ';' + accept + ';' + user + ';' + link)
|
||||
n += 1
|
||||
except:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
continue
|
||||
|
||||
data['DIR'] = sorted(dirnames)
|
||||
|
||||
+9
-8
@@ -10,7 +10,6 @@ import shlex
|
||||
import datetime
|
||||
import subprocess
|
||||
import re
|
||||
import hashlib
|
||||
|
||||
import db
|
||||
|
||||
@@ -143,19 +142,19 @@ def getPageObject(args, result='1,2,3,4,5,8'):
|
||||
info = {}
|
||||
|
||||
info['count'] = 0
|
||||
if args.has_key('count'):
|
||||
if 'count' in args:
|
||||
info['count'] = int(args['count'])
|
||||
|
||||
info['row'] = 10
|
||||
if args.has_key('row'):
|
||||
if 'row' in args:
|
||||
info['row'] = int(args['row'])
|
||||
|
||||
info['p'] = 1
|
||||
if args.has_key('p'):
|
||||
if 'p' in args:
|
||||
info['p'] = int(args['p'])
|
||||
info['uri'] = {}
|
||||
info['return_js'] = ''
|
||||
if args.has_key('tojs'):
|
||||
if 'tojs' in args:
|
||||
info['return_js'] = args['tojs']
|
||||
|
||||
return (page.GetPage(info, result), page)
|
||||
@@ -165,9 +164,10 @@ def md5(str):
|
||||
# 生成MD5
|
||||
try:
|
||||
m = hashlib.md5()
|
||||
m.update(str)
|
||||
m.update(str.encode("utf-8"))
|
||||
return m.hexdigest()
|
||||
except:
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
return False
|
||||
|
||||
|
||||
@@ -273,7 +273,8 @@ def readFile(filename):
|
||||
fBody = fp.read()
|
||||
fp.close()
|
||||
return fBody
|
||||
except:
|
||||
except Exception as e:
|
||||
# print('readFile:', e)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
+27
-23
@@ -55,7 +55,6 @@ class Page():
|
||||
self.SHIFT = self.__START_NUM - 1
|
||||
|
||||
keys = limit.split(',')
|
||||
|
||||
pages = {}
|
||||
# 起始页
|
||||
pages['1'] = self.__GetStart()
|
||||
@@ -70,14 +69,16 @@ class Page():
|
||||
|
||||
# 当前显示页与总页数
|
||||
pages['6'] = "<span class='Pnumber'>" + \
|
||||
bytes(self.__C_PAGE) + "/" + bytes(self.__COUNT_PAGE) + "</span>"
|
||||
str(self.__C_PAGE) + "/" + \
|
||||
str(self.__COUNT_PAGE) + "</span>"
|
||||
|
||||
# 本页显示开始与结束行
|
||||
pages['7'] = "<span class='Pline'>" + self.__FO + \
|
||||
bytes(self.__START_NUM) + "-" + \
|
||||
bytes(self.__END_NUM) + self.__LINE + "</span>"
|
||||
pages['7'] = "<span class='Pline'>" + str(self.__FO) + \
|
||||
str(self.__START_NUM) + "-" + \
|
||||
str(self.__END_NUM) + str(self.__LINE) + "</span>"
|
||||
# 行数
|
||||
pages['8'] = "<span class='Pcount'>" + self.__COUNT_START + \
|
||||
bytes(self.__COUNT_ROW) + self.__COUNT_END + "</span>"
|
||||
pages['8'] = "<span class='Pcount'>" + str(self.__COUNT_START) + \
|
||||
str(self.__COUNT_ROW) + str(self.__COUNT_END) + "</span>"
|
||||
|
||||
# 构造返回数据
|
||||
retuls = '<div>'
|
||||
@@ -96,10 +97,11 @@ class Page():
|
||||
else:
|
||||
if self.__RTURN_JS == "":
|
||||
endStr = "<a class='Pend' href='" + self.__URI + "p=" + \
|
||||
bytes(self.__COUNT_PAGE) + "'>" + self.__END + "</a>"
|
||||
str(self.__COUNT_PAGE) + "'>" + str(self.__END) + "</a>"
|
||||
else:
|
||||
endStr = "<a class='Pend' onclick='" + self.__RTURN_JS + \
|
||||
"(" + bytes(self.__COUNT_PAGE) + ")'>" + self.__END + "</a>"
|
||||
"(" + str(self.__COUNT_PAGE) + ")'>" + \
|
||||
str(self.__END) + "</a>"
|
||||
return endStr
|
||||
|
||||
def __GetNext(self):
|
||||
@@ -110,10 +112,11 @@ class Page():
|
||||
else:
|
||||
if self.__RTURN_JS == "":
|
||||
nextStr = "<a class='Pnext' href='" + self.__URI + "p=" + \
|
||||
bytes(self.__C_PAGE + 1) + "'>" + self.__NEXT + "</a>"
|
||||
str(self.__C_PAGE + 1) + "'>" + str(self.__NEXT) + "</a>"
|
||||
else:
|
||||
nextStr = "<a class='Pnext' onclick='" + self.__RTURN_JS + \
|
||||
"(" + bytes(self.__C_PAGE + 1) + ")'>" + self.__NEXT + "</a>"
|
||||
"(" + str(self.__C_PAGE + 1) + ")'>" + \
|
||||
str(self.__NEXT) + "</a>"
|
||||
|
||||
return nextStr
|
||||
|
||||
@@ -134,15 +137,15 @@ class Page():
|
||||
if page > 0:
|
||||
if self.__RTURN_JS == "":
|
||||
pages += "<a class='Pnum' href='" + self.__URI + \
|
||||
"p=" + bytes(page) + "'>" + bytes(page) + "</a>"
|
||||
"p=" + str(page) + "'>" + str(page) + "</a>"
|
||||
else:
|
||||
pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \
|
||||
"(" + bytes(page) + ")'>" + bytes(page) + "</a>"
|
||||
"(" + str(page) + ")'>" + str(page) + "</a>"
|
||||
|
||||
# 当前页
|
||||
if self.__C_PAGE > 0:
|
||||
pages += "<span class='Pcurrent'>" + \
|
||||
bytes(self.__C_PAGE) + "</span>"
|
||||
str(self.__C_PAGE) + "</span>"
|
||||
|
||||
# 当前页之后
|
||||
if self.__C_PAGE <= self.__LIST_NUM:
|
||||
@@ -157,10 +160,10 @@ class Page():
|
||||
break
|
||||
if self.__RTURN_JS == "":
|
||||
pages += "<a class='Pnum' href='" + self.__URI + \
|
||||
"p=" + bytes(page) + "'>" + bytes(page) + "</a>"
|
||||
"p=" + str(page) + "'>" + str(page) + "</a>"
|
||||
else:
|
||||
pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \
|
||||
"(" + bytes(page) + ")'>" + bytes(page) + "</a>"
|
||||
"(" + str(page) + ")'>" + str(page) + "</a>"
|
||||
|
||||
return pages
|
||||
|
||||
@@ -172,10 +175,11 @@ class Page():
|
||||
else:
|
||||
if self.__RTURN_JS == "":
|
||||
startStr = "<a class='Ppren' href='" + self.__URI + "p=" + \
|
||||
bytes(self.__C_PAGE - 1) + "'>" + self.__PREV + "</a>"
|
||||
str(self.__C_PAGE - 1) + "'>" + str(self.__PREV) + "</a>"
|
||||
else:
|
||||
startStr = "<a class='Ppren' onclick='" + self.__RTURN_JS + \
|
||||
"(" + bytes(self.__C_PAGE - 1) + ")'>" + self.__PREV + "</a>"
|
||||
"(" + str(self.__C_PAGE - 1) + ")'>" + \
|
||||
str(self.__PREV) + "</a>"
|
||||
return startStr
|
||||
|
||||
def __GetStart(self):
|
||||
@@ -186,10 +190,10 @@ class Page():
|
||||
else:
|
||||
if self.__RTURN_JS == "":
|
||||
startStr = "<a class='Pstart' href='" + \
|
||||
self.__URI + "p=1'>" + self.__START + "</a>"
|
||||
self.__URI + "p=1'>" + str(self.__START) + "</a>"
|
||||
else:
|
||||
startStr = "<a class='Pstart' onclick='" + \
|
||||
self.__RTURN_JS + "(1)'>" + self.__START + "</a>"
|
||||
self.__RTURN_JS + "(1)'>" + str(self.__START) + "</a>"
|
||||
return startStr
|
||||
|
||||
def __GetCpage(self, p):
|
||||
@@ -212,11 +216,11 @@ class Page():
|
||||
# 取总页数
|
||||
return int(math.ceil(self.__COUNT_ROW / float(self.ROW)))
|
||||
|
||||
def __SetUri(self, input):
|
||||
def __SetUri(self, sinput):
|
||||
# 构造URI
|
||||
uri = '?'
|
||||
for key in input:
|
||||
for key in sinput:
|
||||
if key == 'p':
|
||||
continue
|
||||
uri += key + '=' + input[key] + '&'
|
||||
uri += key + '=' + sinput[key] + '&'
|
||||
return str(uri)
|
||||
|
||||
+35
-24
@@ -8,8 +8,9 @@ import re
|
||||
import json
|
||||
|
||||
import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
|
||||
# reload(sys)
|
||||
# sys.setdefaultencoding('utf8')
|
||||
|
||||
import threading
|
||||
import multiprocessing
|
||||
@@ -61,11 +62,11 @@ class plugins_api:
|
||||
if f.strip() == '':
|
||||
return ''
|
||||
|
||||
file = self.__plugin_dir + '/' + name + '/' + f
|
||||
file = mw.getPluginDir() + '/' + name + '/' + f
|
||||
if not os.path.exists(file):
|
||||
return ''
|
||||
|
||||
c = mw.readFile(file)
|
||||
c = open(file, 'rb').read()
|
||||
return c
|
||||
|
||||
def indexListApi(self):
|
||||
@@ -166,8 +167,8 @@ class plugins_api:
|
||||
|
||||
data = mw.execShell(execstr)
|
||||
if mw.isAppleSystem():
|
||||
print execstr
|
||||
print data[0], data[1]
|
||||
print(execstr)
|
||||
print(data[0], data[1])
|
||||
return mw.returnJson(True, '卸载执行成功!')
|
||||
# if data[1] == '':
|
||||
# return mw.returnJson(True, '已将卸载成功!')
|
||||
@@ -206,8 +207,10 @@ class plugins_api:
|
||||
|
||||
data = self.run(name, func, version, args, script)
|
||||
if data[1] == '':
|
||||
return mw.returnJson(True, "OK", data[0].strip())
|
||||
return mw.returnJson(False, data[1].strip())
|
||||
r = mw.returnJson(True, "OK", data[0].strip())
|
||||
r = mw.returnJson(False, data[1].strip())
|
||||
|
||||
return r
|
||||
|
||||
def callbackApi(self):
|
||||
name = request.form.get('name', '')
|
||||
@@ -284,7 +287,7 @@ class plugins_api:
|
||||
return mw.returnJson(False, '临时文件不存在,请重新上传!')
|
||||
plugin_path = mw.getPluginDir() + '/' + plugin_name
|
||||
if not os.path.exists(plugin_path):
|
||||
print mw.execShell('mkdir -p ' + plugin_path)
|
||||
print(mw.execShell('mkdir -p ' + plugin_path))
|
||||
mw.execShell("\cp -rf " + tmp_path + '/* ' + plugin_path + '/')
|
||||
mw.execShell('chmod -R 755 ' + plugin_path)
|
||||
p_info = mw.readFile(plugin_path + '/info.json')
|
||||
@@ -382,7 +385,7 @@ class plugins_api:
|
||||
t = threads[i].getResult()
|
||||
plugins_info[i]['status'] = t
|
||||
except Exception as e:
|
||||
print 'checkStatusMThreads:', str(e)
|
||||
print('checkStatusMThreads:', str(e))
|
||||
|
||||
return plugins_info
|
||||
|
||||
@@ -438,13 +441,13 @@ class plugins_api:
|
||||
else:
|
||||
checks = mw.getRootDir() + '/' + info['checks']
|
||||
|
||||
if info.has_key('path'):
|
||||
if 'path' in info:
|
||||
path = info['path']
|
||||
|
||||
if path[0:1] != '/':
|
||||
path = mw.getRootDir() + '/' + path
|
||||
|
||||
if info.has_key('coexist') and info['coexist']:
|
||||
if 'coexist' in info and info['coexist']:
|
||||
coexist = True
|
||||
|
||||
pInfo = {
|
||||
@@ -507,7 +510,7 @@ class plugins_api:
|
||||
plugins_info = []
|
||||
|
||||
if (data['pid'] == sType):
|
||||
if type(data['versions']) == list and data.has_key('coexist') and data['coexist']:
|
||||
if type(data['versions']) == list and 'coexist' in data and data['coexist']:
|
||||
tmp_data = self.makeCoexist(data)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
@@ -517,7 +520,7 @@ class plugins_api:
|
||||
return plugins_info
|
||||
|
||||
if sType == '0':
|
||||
if type(data['versions']) == list and data.has_key('coexist') and data['coexist']:
|
||||
if type(data['versions']) == list and 'coexist' in data and data['coexist']:
|
||||
tmp_data = self.makeCoexist(data)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
@@ -542,8 +545,8 @@ class plugins_api:
|
||||
tmp_data = self.makeList(data, sType)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return plugins_info
|
||||
|
||||
def getAllListPage(self, sType='0', page=1, pageSize=10):
|
||||
@@ -560,8 +563,8 @@ class plugins_api:
|
||||
tmp_data = self.makeList(data, sType)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
start = (page - 1) * pageSize
|
||||
end = start + pageSize
|
||||
@@ -733,8 +736,8 @@ class plugins_api:
|
||||
tmp_data[index]['display'] = True
|
||||
plist.append(tmp_data[index])
|
||||
continue
|
||||
except Exception, e:
|
||||
print 'getIndexList:', e
|
||||
except Exception as e:
|
||||
print('getIndexList:', e)
|
||||
|
||||
# 使用gevent模式时,无法使用多进程
|
||||
# plist = self.checkStatusMProcess(plist)
|
||||
@@ -788,12 +791,20 @@ class plugins_api:
|
||||
if not os.path.exists(path):
|
||||
return ('', '')
|
||||
data = mw.execShell(py_cmd)
|
||||
# data = os.popen(py_cmd).read()
|
||||
|
||||
if mw.isAppleSystem():
|
||||
print 'run', py_cmd
|
||||
print('run', py_cmd)
|
||||
# print os.path.exists(py_cmd)
|
||||
return (data[0].strip(), data[1].strip())
|
||||
|
||||
t1 = ''
|
||||
t2 = ''
|
||||
if isinstance(data[1], bytes):
|
||||
t1 = str(data[1], encoding='utf-8')
|
||||
|
||||
if isinstance(data[0], bytes):
|
||||
t2 = str(data[0], encoding='utf-8')
|
||||
|
||||
return (t1.strip(), t2.strip())
|
||||
|
||||
# 映射包调用
|
||||
def callback(self, name, func, args='', script='index'):
|
||||
@@ -805,6 +816,6 @@ class plugins_api:
|
||||
eval_str = "__import__('" + script + "')." + func + '(' + args + ')'
|
||||
newRet = eval(eval_str)
|
||||
if mw.isAppleSystem():
|
||||
print 'callback', eval_str
|
||||
print('callback', eval_str)
|
||||
|
||||
return (True, newRet)
|
||||
|
||||
@@ -648,8 +648,8 @@ class site_api:
|
||||
|
||||
# print home_cert
|
||||
cmd = 'export ACCOUNT_EMAIL=' + email + ' && ' + execStr
|
||||
print domains
|
||||
print cmd
|
||||
print(domains)
|
||||
print(cmd)
|
||||
result = mw.execShell(cmd)
|
||||
|
||||
if not os.path.exists(home_cert.replace("\*", "*")):
|
||||
@@ -1064,7 +1064,7 @@ class site_api:
|
||||
|
||||
# self.closeHasPwd(get)
|
||||
filename = self.passPath + '/' + siteName + '.pass'
|
||||
print filename
|
||||
print(filename)
|
||||
passconf = username + ':' + mw.hasPwd(password)
|
||||
|
||||
if siteName == 'phpmyadmin':
|
||||
@@ -1266,7 +1266,7 @@ class site_api:
|
||||
mid = request.form.get('id', '').encode('utf-8')
|
||||
site_ids = json.loads(site_ids)
|
||||
for sid in site_ids:
|
||||
print mw.M('sites').where('id=?', (sid,)).setField('type_id', mid)
|
||||
print(mw.M('sites').where('id=?', (sid,)).setField('type_id', mid))
|
||||
return mw.returnJson(True, "设置成功!")
|
||||
|
||||
##### ----- end ----- ###
|
||||
|
||||
@@ -20,7 +20,7 @@ from threading import Thread
|
||||
from time import sleep
|
||||
|
||||
|
||||
def async(f):
|
||||
def mw_async(f):
|
||||
def wrapper(*args, **kwargs):
|
||||
thr = Thread(target=f, args=args, kwargs=kwargs)
|
||||
thr.start()
|
||||
@@ -101,14 +101,14 @@ class system_api:
|
||||
return mw.returnJson(True, '正在重启服务器!')
|
||||
##### ----- end ----- ###
|
||||
|
||||
@async
|
||||
@mw_async
|
||||
def restartMw(self):
|
||||
sleep(0.3)
|
||||
# cmd = mw.getRunDir() + '/scripts/init.d/mw restart'
|
||||
# print cmd
|
||||
mw.execShell('service mw restart')
|
||||
|
||||
@async
|
||||
@mw_async
|
||||
def restartServer(self):
|
||||
if not mw.isRestart():
|
||||
return mw.returnJson(False, '请等待所有安装任务完成再执行!')
|
||||
@@ -302,7 +302,7 @@ class system_api:
|
||||
memInfo['memBuffers'] - memInfo['memCached']
|
||||
tmp1 = memInfo['memTotal'] / 100
|
||||
return (tmp / tmp1)
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
return 1
|
||||
|
||||
def getDiskInfo(self, get=None):
|
||||
@@ -396,7 +396,7 @@ class system_api:
|
||||
shutil.rmtree(filename)
|
||||
else:
|
||||
os.remove(filename)
|
||||
print '\t\033[1;32m[OK]\033[0m'
|
||||
print('\t\033[1;32m[OK]\033[0m')
|
||||
num += 1
|
||||
total += size
|
||||
count += num
|
||||
@@ -460,8 +460,8 @@ class system_api:
|
||||
networkInfo['mem'] = self.getMemInfo()
|
||||
|
||||
return networkInfo
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return None
|
||||
|
||||
def getNetWorkApi(self):
|
||||
@@ -621,7 +621,7 @@ class system_api:
|
||||
version = json.loads(r.content)
|
||||
return version[0]
|
||||
except Exception as e:
|
||||
print 'getServerInfo', e
|
||||
print('getServerInfo', e)
|
||||
return {}
|
||||
|
||||
def updateServer(self, stype, version=''):
|
||||
@@ -680,7 +680,7 @@ class system_api:
|
||||
|
||||
return mw.returnJson(False, '已经是最新,无需更新!')
|
||||
except Exception as ex:
|
||||
print 'updateServer', ex
|
||||
print('updateServer', ex)
|
||||
return mw.returnJson(False, "连接服务器失败!")
|
||||
|
||||
# 修复面板
|
||||
|
||||
@@ -75,7 +75,7 @@ class vieCode:
|
||||
if not self.__inNoise:
|
||||
return
|
||||
font = ImageFont.truetype(self.__fontPatn, int(self.__fontSize / 1.5))
|
||||
for i in xrange(5):
|
||||
for i in range(5):
|
||||
# 杂点颜色
|
||||
noiseColor = (random.randint(150, 200), random.randint(
|
||||
150, 200), random.randint(150, 200))
|
||||
@@ -104,9 +104,9 @@ class vieCode:
|
||||
# 画曲线
|
||||
color = (random.randint(30, 150), random.randint(
|
||||
30, 150), random.randint(30, 150))
|
||||
for x in xrange(xend):
|
||||
for x in range(xend):
|
||||
if w != 0:
|
||||
for k in xrange(int(self.__heigth / 10)):
|
||||
for k in range(int(self.__heigth / 10)):
|
||||
y = a * math.sin(w * x + f) + b + self.__heigth / 2
|
||||
i = int(self.__fontSize / 5)
|
||||
while i > 0:
|
||||
@@ -120,7 +120,7 @@ class vieCode:
|
||||
font = ImageFont.truetype(self.__fontPatn, self.__fontSize)
|
||||
x = 0
|
||||
# 打印字符到画板
|
||||
for i in xrange(self.__length):
|
||||
for i in range(self.__length):
|
||||
# 设置字体随机颜色
|
||||
color = (random.randint(30, 150), random.randint(
|
||||
30, 150), random.randint(30, 150))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
jnuxgfkj
|
||||
+11
-11
@@ -188,24 +188,24 @@ def getLog():
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print status()
|
||||
print(status())
|
||||
elif func == 'start':
|
||||
print start()
|
||||
print(start())
|
||||
elif func == 'stop':
|
||||
print stop()
|
||||
print(stop())
|
||||
elif func == 'restart':
|
||||
print restart()
|
||||
print(restart())
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
print(reload())
|
||||
elif func == 'conf':
|
||||
print getPathFile()
|
||||
print(getPathFile())
|
||||
elif func == 'initd_status':
|
||||
print initdStatus()
|
||||
print(initdStatus())
|
||||
elif func == 'initd_install':
|
||||
print initdInstall()
|
||||
print(initdInstall())
|
||||
elif func == 'initd_uninstall':
|
||||
print initdUinstall()
|
||||
print(initdUinstall())
|
||||
elif func == 'run_log':
|
||||
print getLog()
|
||||
print(getLog())
|
||||
else:
|
||||
print 'error'
|
||||
print('error')
|
||||
|
||||
@@ -98,12 +98,12 @@ def reload():
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print status()
|
||||
print(status())
|
||||
elif func == 'start':
|
||||
print start()
|
||||
print(start())
|
||||
elif func == 'stop':
|
||||
print stop()
|
||||
print(stop())
|
||||
elif func == 'restart':
|
||||
print restart()
|
||||
print(restart())
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
print(reload())
|
||||
|
||||
+25
-25
@@ -658,52 +658,52 @@ def getTotalStatistics():
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print status()
|
||||
print(status())
|
||||
elif func == 'start':
|
||||
print start()
|
||||
print(start())
|
||||
elif func == 'stop':
|
||||
print stop()
|
||||
print(stop())
|
||||
elif func == 'restart':
|
||||
print restart()
|
||||
print(restart())
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
print(reload())
|
||||
elif func == 'initd_status':
|
||||
print initdStatus()
|
||||
print(initdStatus())
|
||||
elif func == 'initd_install':
|
||||
print initdInstall()
|
||||
print(initdInstall())
|
||||
elif func == 'initd_uninstall':
|
||||
print initdUinstall()
|
||||
print(initdUinstall())
|
||||
elif func == 'csvn_edit':
|
||||
print csvnEdit()
|
||||
print(csvnEdit())
|
||||
elif func == 'user_list':
|
||||
print userList()
|
||||
print(userList())
|
||||
elif func == 'user_add':
|
||||
print userAdd()
|
||||
print(userAdd())
|
||||
elif func == 'user_del':
|
||||
print userDel()
|
||||
print(userDel())
|
||||
elif func == 'project_list':
|
||||
print projectList()
|
||||
print(projectList())
|
||||
elif func == 'project_del':
|
||||
print projectDel()
|
||||
print(projectDel())
|
||||
elif func == 'project_add':
|
||||
print projectAdd()
|
||||
print(projectAdd())
|
||||
elif func == 'project_acl_list':
|
||||
print projectAclList()
|
||||
print(projectAclList())
|
||||
elif func == 'project_acl_add':
|
||||
print projectAclAdd()
|
||||
print(projectAclAdd())
|
||||
elif func == 'project_acl_del':
|
||||
print projectAclDel()
|
||||
print(projectAclDel())
|
||||
elif func == 'project_acl_set':
|
||||
print projectAclSet()
|
||||
print(projectAclSet())
|
||||
elif func == 'project_script_load':
|
||||
print projectScriptLoad()
|
||||
print(projectScriptLoad())
|
||||
elif func == 'project_script_unload':
|
||||
print projectScriptUnload()
|
||||
print(projectScriptUnload())
|
||||
elif func == 'project_script_edit':
|
||||
print projectScriptEdit()
|
||||
print(projectScriptEdit())
|
||||
elif func == 'project_script_debug':
|
||||
print projectScriptDebug()
|
||||
print(projectScriptDebug())
|
||||
elif func == 'get_total_statistics':
|
||||
print getTotalStatistics()
|
||||
print(getTotalStatistics())
|
||||
else:
|
||||
print 'fail'
|
||||
print('fail')
|
||||
|
||||
+24
-24
@@ -637,50 +637,50 @@ def getTotalStatistics():
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print status()
|
||||
print(status())
|
||||
elif func == 'start':
|
||||
print start()
|
||||
print(start())
|
||||
elif func == 'stop':
|
||||
print stop()
|
||||
print(stop())
|
||||
elif func == 'restart':
|
||||
print restart()
|
||||
print(restart())
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
print(reload())
|
||||
elif func == 'initd_status':
|
||||
print initdStatus()
|
||||
print(initdStatus())
|
||||
elif func == 'initd_install':
|
||||
print initdInstall()
|
||||
print(initdInstall())
|
||||
elif func == 'initd_uninstall':
|
||||
print initdUinstall()
|
||||
print(initdUinstall())
|
||||
elif func == 'run_log':
|
||||
print runLog()
|
||||
print(runLog())
|
||||
elif func == 'post_receive_log':
|
||||
print postReceiveLog()
|
||||
print(postReceiveLog())
|
||||
elif func == 'conf':
|
||||
print getConf()
|
||||
print(getConf())
|
||||
elif func == 'init_conf':
|
||||
print getInitdConf()
|
||||
print(getInitdConf())
|
||||
elif func == 'get_gogs_conf':
|
||||
print getGogsConf()
|
||||
print(getGogsConf())
|
||||
elif func == 'submit_gogs_conf':
|
||||
print submitGogsConf()
|
||||
print(submitGogsConf())
|
||||
elif func == 'user_list':
|
||||
print userList()
|
||||
print(userList())
|
||||
elif func == 'user_project_list':
|
||||
print userProjectList()
|
||||
print(userProjectList())
|
||||
elif func == 'project_script_edit':
|
||||
print projectScriptEdit()
|
||||
print(projectScriptEdit())
|
||||
elif func == 'project_script_load':
|
||||
print projectScriptLoad()
|
||||
print(projectScriptLoad())
|
||||
elif func == 'project_script_unload':
|
||||
print projectScriptUnload()
|
||||
print(projectScriptUnload())
|
||||
elif func == 'project_script_debug':
|
||||
print projectScriptDebug()
|
||||
print(projectScriptDebug())
|
||||
elif func == 'gogs_edit':
|
||||
print gogsEdit()
|
||||
print(gogsEdit())
|
||||
elif func == 'get_rsa_public':
|
||||
print getRsaPublic()
|
||||
print(getRsaPublic())
|
||||
elif func == 'get_total_statistics':
|
||||
print getTotalStatistics()
|
||||
print(getTotalStatistics())
|
||||
else:
|
||||
print 'fail'
|
||||
print('fail')
|
||||
|
||||
@@ -172,24 +172,24 @@ def getLog():
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print status()
|
||||
print(status())
|
||||
elif func == 'start':
|
||||
print start()
|
||||
print(start())
|
||||
elif func == 'stop':
|
||||
print stop()
|
||||
print(stop())
|
||||
elif func == 'restart':
|
||||
print restart()
|
||||
print(restart())
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
print(reload())
|
||||
elif func == 'conf':
|
||||
print getPathFile()
|
||||
print(getPathFile())
|
||||
elif func == 'initd_status':
|
||||
print initdStatus()
|
||||
print(initdStatus())
|
||||
elif func == 'initd_install':
|
||||
print initdInstall()
|
||||
print(initdInstall())
|
||||
elif func == 'initd_uninstall':
|
||||
print initdUinstall()
|
||||
print(initdUinstall())
|
||||
elif func == 'run_log':
|
||||
print getLog()
|
||||
print(getLog())
|
||||
else:
|
||||
print 'error'
|
||||
print('error')
|
||||
|
||||
+1
-1
@@ -10,12 +10,12 @@ gunicorn==19.9
|
||||
gevent==21.1.2
|
||||
gevent-websocket
|
||||
psutil==5.6.6
|
||||
pillow==6.2.2
|
||||
chardet==3.0.4
|
||||
flask-sqlalchemy==2.3.2
|
||||
cryptography==3.3.2
|
||||
requests==2.20.0
|
||||
ConfigParser==3.5.0
|
||||
MySQL-python==1.2.5
|
||||
mysql-connector-python
|
||||
flask-socketio==3.0.1
|
||||
python-engineio==3.9.0
|
||||
|
||||
+17
-9
@@ -135,14 +135,16 @@ def code():
|
||||
import vilidate
|
||||
vie = vilidate.vieCode()
|
||||
codeImage = vie.GetCodeImage(80, 4)
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except:
|
||||
from StringIO import StringIO
|
||||
# try:
|
||||
# from cStringIO import StringIO
|
||||
# except:
|
||||
# from StringIO import StringIO
|
||||
|
||||
out = StringIO()
|
||||
out = io.BytesIO()
|
||||
codeImage[0].save(out, "png")
|
||||
|
||||
print(codeImage[1])
|
||||
|
||||
session['code'] = mw.md5(''.join(codeImage[1]).lower())
|
||||
|
||||
img = Response(out.getvalue(), headers={'Content-Type': 'image/png'})
|
||||
@@ -174,15 +176,21 @@ def doLogin():
|
||||
username = request.form.get('username', '').strip()
|
||||
password = request.form.get('password', '').strip()
|
||||
code = request.form.get('code', '').strip()
|
||||
|
||||
if session.has_key('code'):
|
||||
if session['code'] != mw.md5(code):
|
||||
return mw.returnJson(False, '验证码错误,请重新输入!')
|
||||
print(session)
|
||||
# if 'code' in session:
|
||||
# if session['code'] != mw.md5(code):
|
||||
# return mw.returnJson(False, '验证码错误,请重新输入!')
|
||||
|
||||
userInfo = mw.M('users').where(
|
||||
"id=?", (1,)).field('id,username,password').find()
|
||||
|
||||
print(userInfo)
|
||||
print(password)
|
||||
|
||||
password = mw.md5(password)
|
||||
|
||||
print('md5-pass', password)
|
||||
|
||||
login_cache_count = 5
|
||||
login_cache_limit = cache.get('login_cache_limit')
|
||||
filename = 'data/close.pl'
|
||||
|
||||
Reference in New Issue
Block a user