py3升级.1

pull/109/head
midoks 4 years ago
parent ce537c4b8a
commit 463b76e8b1
  1. 10
      class/core/files_api.py
  2. 17
      class/core/mw.py
  3. 50
      class/core/page.py
  4. 59
      class/core/plugins_api.py
  5. 8
      class/core/site_api.py
  6. 18
      class/core/system_api.py
  7. 8
      class/core/vilidate.py
  8. 1
      data/api_login.txt
  9. 22
      plugins/aria2/index.py
  10. 10
      plugins/bbr/index.py
  11. 50
      plugins/csvn/index.py
  12. 48
      plugins/gogs/index.py
  13. 22
      plugins/shadowsocks/index.py
  14. 2
      requirements.txt
  15. 26
      route/__init__.py

@ -272,7 +272,8 @@ done
data['dirs'].append(tmp) data['dirs'].append(tmp)
else: else:
data['files'].append(tmp) data['files'].append(tmp)
except: except Exception as e:
print(e)
continue continue
return mw.returnJson(True, 'OK', data) return mw.returnJson(True, 'OK', data)
@ -451,7 +452,7 @@ done
else: else:
filesx.append(filename) filesx.append(filename)
print filesx # print(filesx)
for fn in filesx: for fn in filesx:
if fn == '.': if fn == '.':
@ -795,6 +796,8 @@ done
pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8') pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8')
data['PAGE'] = pageObj[0] data['PAGE'] = pageObj[0]
print('....eeee.11..')
i = 0 i = 0
n = 0 n = 0
for filename in os.listdir(path): for filename in os.listdir(path):
@ -834,7 +837,8 @@ done
filenames.append(filename + ';' + size + ';' + filenames.append(filename + ';' + size + ';' +
mtime + ';' + accept + ';' + user + ';' + link) mtime + ';' + accept + ';' + user + ';' + link)
n += 1 n += 1
except: except Exception as e:
print(e)
continue continue
data['DIR'] = sorted(dirnames) data['DIR'] = sorted(dirnames)

@ -10,7 +10,6 @@ import shlex
import datetime import datetime
import subprocess import subprocess
import re import re
import hashlib
import db import db
@ -143,19 +142,19 @@ def getPageObject(args, result='1,2,3,4,5,8'):
info = {} info = {}
info['count'] = 0 info['count'] = 0
if args.has_key('count'): if 'count' in args:
info['count'] = int(args['count']) info['count'] = int(args['count'])
info['row'] = 10 info['row'] = 10
if args.has_key('row'): if 'row' in args:
info['row'] = int(args['row']) info['row'] = int(args['row'])
info['p'] = 1 info['p'] = 1
if args.has_key('p'): if 'p' in args:
info['p'] = int(args['p']) info['p'] = int(args['p'])
info['uri'] = {} info['uri'] = {}
info['return_js'] = '' info['return_js'] = ''
if args.has_key('tojs'): if 'tojs' in args:
info['return_js'] = args['tojs'] info['return_js'] = args['tojs']
return (page.GetPage(info, result), page) return (page.GetPage(info, result), page)
@ -165,9 +164,10 @@ def md5(str):
# 生成MD5 # 生成MD5
try: try:
m = hashlib.md5() m = hashlib.md5()
m.update(str) m.update(str.encode("utf-8"))
return m.hexdigest() return m.hexdigest()
except: except Exception as ex:
print(ex)
return False return False
@ -273,7 +273,8 @@ def readFile(filename):
fBody = fp.read() fBody = fp.read()
fp.close() fp.close()
return fBody return fBody
except: except Exception as e:
# print('readFile:', e)
return False return False

@ -55,7 +55,6 @@ class Page():
self.SHIFT = self.__START_NUM - 1 self.SHIFT = self.__START_NUM - 1
keys = limit.split(',') keys = limit.split(',')
pages = {} pages = {}
# 起始页 # 起始页
pages['1'] = self.__GetStart() pages['1'] = self.__GetStart()
@ -70,14 +69,16 @@ class Page():
# 当前显示页与总页数 # 当前显示页与总页数
pages['6'] = "<span class='Pnumber'>" + \ 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 + \ pages['7'] = "<span class='Pline'>" + str(self.__FO) + \
bytes(self.__START_NUM) + "-" + \ str(self.__START_NUM) + "-" + \
bytes(self.__END_NUM) + self.__LINE + "</span>" str(self.__END_NUM) + str(self.__LINE) + "</span>"
# 行数 # 行数
pages['8'] = "<span class='Pcount'>" + self.__COUNT_START + \ pages['8'] = "<span class='Pcount'>" + str(self.__COUNT_START) + \
bytes(self.__COUNT_ROW) + self.__COUNT_END + "</span>" str(self.__COUNT_ROW) + str(self.__COUNT_END) + "</span>"
# 构造返回数据 # 构造返回数据
retuls = '<div>' retuls = '<div>'
@ -96,10 +97,11 @@ class Page():
else: else:
if self.__RTURN_JS == "": if self.__RTURN_JS == "":
endStr = "<a class='Pend' href='" + self.__URI + "p=" + \ endStr = "<a class='Pend' href='" + self.__URI + "p=" + \
bytes(self.__COUNT_PAGE) + "'>" + self.__END + "</a>" str(self.__COUNT_PAGE) + "'>" + str(self.__END) + "</a>"
else: else:
endStr = "<a class='Pend' onclick='" + self.__RTURN_JS + \ 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 return endStr
def __GetNext(self): def __GetNext(self):
@ -110,10 +112,11 @@ class Page():
else: else:
if self.__RTURN_JS == "": if self.__RTURN_JS == "":
nextStr = "<a class='Pnext' href='" + self.__URI + "p=" + \ 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: else:
nextStr = "<a class='Pnext' onclick='" + self.__RTURN_JS + \ 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 return nextStr
@ -134,15 +137,15 @@ class Page():
if page > 0: if page > 0:
if self.__RTURN_JS == "": if self.__RTURN_JS == "":
pages += "<a class='Pnum' href='" + self.__URI + \ pages += "<a class='Pnum' href='" + self.__URI + \
"p=" + bytes(page) + "'>" + bytes(page) + "</a>" "p=" + str(page) + "'>" + str(page) + "</a>"
else: else:
pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \ pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \
"(" + bytes(page) + ")'>" + bytes(page) + "</a>" "(" + str(page) + ")'>" + str(page) + "</a>"
# 当前页 # 当前页
if self.__C_PAGE > 0: if self.__C_PAGE > 0:
pages += "<span class='Pcurrent'>" + \ pages += "<span class='Pcurrent'>" + \
bytes(self.__C_PAGE) + "</span>" str(self.__C_PAGE) + "</span>"
# 当前页之后 # 当前页之后
if self.__C_PAGE <= self.__LIST_NUM: if self.__C_PAGE <= self.__LIST_NUM:
@ -157,10 +160,10 @@ class Page():
break break
if self.__RTURN_JS == "": if self.__RTURN_JS == "":
pages += "<a class='Pnum' href='" + self.__URI + \ pages += "<a class='Pnum' href='" + self.__URI + \
"p=" + bytes(page) + "'>" + bytes(page) + "</a>" "p=" + str(page) + "'>" + str(page) + "</a>"
else: else:
pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \ pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \
"(" + bytes(page) + ")'>" + bytes(page) + "</a>" "(" + str(page) + ")'>" + str(page) + "</a>"
return pages return pages
@ -172,10 +175,11 @@ class Page():
else: else:
if self.__RTURN_JS == "": if self.__RTURN_JS == "":
startStr = "<a class='Ppren' href='" + self.__URI + "p=" + \ 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: else:
startStr = "<a class='Ppren' onclick='" + self.__RTURN_JS + \ 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 return startStr
def __GetStart(self): def __GetStart(self):
@ -186,10 +190,10 @@ class Page():
else: else:
if self.__RTURN_JS == "": if self.__RTURN_JS == "":
startStr = "<a class='Pstart' href='" + \ startStr = "<a class='Pstart' href='" + \
self.__URI + "p=1'>" + self.__START + "</a>" self.__URI + "p=1'>" + str(self.__START) + "</a>"
else: else:
startStr = "<a class='Pstart' onclick='" + \ startStr = "<a class='Pstart' onclick='" + \
self.__RTURN_JS + "(1)'>" + self.__START + "</a>" self.__RTURN_JS + "(1)'>" + str(self.__START) + "</a>"
return startStr return startStr
def __GetCpage(self, p): def __GetCpage(self, p):
@ -212,11 +216,11 @@ class Page():
# 取总页数 # 取总页数
return int(math.ceil(self.__COUNT_ROW / float(self.ROW))) return int(math.ceil(self.__COUNT_ROW / float(self.ROW)))
def __SetUri(self, input): def __SetUri(self, sinput):
# 构造URI # 构造URI
uri = '?' uri = '?'
for key in input: for key in sinput:
if key == 'p': if key == 'p':
continue continue
uri += key + '=' + input[key] + '&' uri += key + '=' + sinput[key] + '&'
return str(uri) return str(uri)

@ -8,8 +8,9 @@ import re
import json import json
import sys import sys
reload(sys)
sys.setdefaultencoding('utf8') # reload(sys)
# sys.setdefaultencoding('utf8')
import threading import threading
import multiprocessing import multiprocessing
@ -61,11 +62,11 @@ class plugins_api:
if f.strip() == '': if f.strip() == '':
return '' return ''
file = self.__plugin_dir + '/' + name + '/' + f file = mw.getPluginDir() + '/' + name + '/' + f
if not os.path.exists(file): if not os.path.exists(file):
return '' return ''
c = mw.readFile(file) c = open(file, 'rb').read()
return c return c
def indexListApi(self): def indexListApi(self):
@ -166,8 +167,8 @@ class plugins_api:
data = mw.execShell(execstr) data = mw.execShell(execstr)
if mw.isAppleSystem(): if mw.isAppleSystem():
print execstr print(execstr)
print data[0], data[1] print(data[0], data[1])
return mw.returnJson(True, '卸载执行成功!') return mw.returnJson(True, '卸载执行成功!')
# if data[1] == '': # if data[1] == '':
# return mw.returnJson(True, '已将卸载成功!') # return mw.returnJson(True, '已将卸载成功!')
@ -206,8 +207,10 @@ class plugins_api:
data = self.run(name, func, version, args, script) data = self.run(name, func, version, args, script)
if data[1] == '': if data[1] == '':
return mw.returnJson(True, "OK", data[0].strip()) r = mw.returnJson(True, "OK", data[0].strip())
return mw.returnJson(False, data[1].strip()) r = mw.returnJson(False, data[1].strip())
return r
def callbackApi(self): def callbackApi(self):
name = request.form.get('name', '') name = request.form.get('name', '')
@ -284,7 +287,7 @@ class plugins_api:
return mw.returnJson(False, '临时文件不存在,请重新上传!') return mw.returnJson(False, '临时文件不存在,请重新上传!')
plugin_path = mw.getPluginDir() + '/' + plugin_name plugin_path = mw.getPluginDir() + '/' + plugin_name
if not os.path.exists(plugin_path): 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("\cp -rf " + tmp_path + '/* ' + plugin_path + '/')
mw.execShell('chmod -R 755 ' + plugin_path) mw.execShell('chmod -R 755 ' + plugin_path)
p_info = mw.readFile(plugin_path + '/info.json') p_info = mw.readFile(plugin_path + '/info.json')
@ -382,7 +385,7 @@ class plugins_api:
t = threads[i].getResult() t = threads[i].getResult()
plugins_info[i]['status'] = t plugins_info[i]['status'] = t
except Exception as e: except Exception as e:
print 'checkStatusMThreads:', str(e) print('checkStatusMThreads:', str(e))
return plugins_info return plugins_info
@ -438,13 +441,13 @@ class plugins_api:
else: else:
checks = mw.getRootDir() + '/' + info['checks'] checks = mw.getRootDir() + '/' + info['checks']
if info.has_key('path'): if 'path' in info:
path = info['path'] path = info['path']
if path[0:1] != '/': if path[0:1] != '/':
path = mw.getRootDir() + '/' + path path = mw.getRootDir() + '/' + path
if info.has_key('coexist') and info['coexist']: if 'coexist' in info and info['coexist']:
coexist = True coexist = True
pInfo = { pInfo = {
@ -507,7 +510,7 @@ class plugins_api:
plugins_info = [] plugins_info = []
if (data['pid'] == sType): 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) tmp_data = self.makeCoexist(data)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index]) plugins_info.append(tmp_data[index])
@ -517,7 +520,7 @@ class plugins_api:
return plugins_info return plugins_info
if sType == '0': 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) tmp_data = self.makeCoexist(data)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index]) plugins_info.append(tmp_data[index])
@ -542,8 +545,8 @@ class plugins_api:
tmp_data = self.makeList(data, sType) tmp_data = self.makeList(data, sType)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index]) plugins_info.append(tmp_data[index])
except Exception, e: except Exception as e:
print e print(e)
return plugins_info return plugins_info
def getAllListPage(self, sType='0', page=1, pageSize=10): def getAllListPage(self, sType='0', page=1, pageSize=10):
@ -560,8 +563,8 @@ class plugins_api:
tmp_data = self.makeList(data, sType) tmp_data = self.makeList(data, sType)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index]) plugins_info.append(tmp_data[index])
except Exception, e: except Exception as e:
print e print(e)
start = (page - 1) * pageSize start = (page - 1) * pageSize
end = start + pageSize end = start + pageSize
@ -733,8 +736,8 @@ class plugins_api:
tmp_data[index]['display'] = True tmp_data[index]['display'] = True
plist.append(tmp_data[index]) plist.append(tmp_data[index])
continue continue
except Exception, e: except Exception as e:
print 'getIndexList:', e print('getIndexList:', e)
# 使用gevent模式时,无法使用多进程 # 使用gevent模式时,无法使用多进程
# plist = self.checkStatusMProcess(plist) # plist = self.checkStatusMProcess(plist)
@ -788,12 +791,20 @@ class plugins_api:
if not os.path.exists(path): if not os.path.exists(path):
return ('', '') return ('', '')
data = mw.execShell(py_cmd) data = mw.execShell(py_cmd)
# data = os.popen(py_cmd).read()
if mw.isAppleSystem(): if mw.isAppleSystem():
print 'run', py_cmd print('run', py_cmd)
# print os.path.exists(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'): def callback(self, name, func, args='', script='index'):
@ -805,6 +816,6 @@ class plugins_api:
eval_str = "__import__('" + script + "')." + func + '(' + args + ')' eval_str = "__import__('" + script + "')." + func + '(' + args + ')'
newRet = eval(eval_str) newRet = eval(eval_str)
if mw.isAppleSystem(): if mw.isAppleSystem():
print 'callback', eval_str print('callback', eval_str)
return (True, newRet) return (True, newRet)

@ -648,8 +648,8 @@ class site_api:
# print home_cert # print home_cert
cmd = 'export ACCOUNT_EMAIL=' + email + ' && ' + execStr cmd = 'export ACCOUNT_EMAIL=' + email + ' && ' + execStr
print domains print(domains)
print cmd print(cmd)
result = mw.execShell(cmd) result = mw.execShell(cmd)
if not os.path.exists(home_cert.replace("\*", "*")): if not os.path.exists(home_cert.replace("\*", "*")):
@ -1064,7 +1064,7 @@ class site_api:
# self.closeHasPwd(get) # self.closeHasPwd(get)
filename = self.passPath + '/' + siteName + '.pass' filename = self.passPath + '/' + siteName + '.pass'
print filename print(filename)
passconf = username + ':' + mw.hasPwd(password) passconf = username + ':' + mw.hasPwd(password)
if siteName == 'phpmyadmin': if siteName == 'phpmyadmin':
@ -1266,7 +1266,7 @@ class site_api:
mid = request.form.get('id', '').encode('utf-8') mid = request.form.get('id', '').encode('utf-8')
site_ids = json.loads(site_ids) site_ids = json.loads(site_ids)
for sid in 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, "设置成功!") return mw.returnJson(True, "设置成功!")
##### ----- end ----- ### ##### ----- end ----- ###

@ -20,7 +20,7 @@ from threading import Thread
from time import sleep from time import sleep
def async(f): def mw_async(f):
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs) thr = Thread(target=f, args=args, kwargs=kwargs)
thr.start() thr.start()
@ -101,14 +101,14 @@ class system_api:
return mw.returnJson(True, '正在重启服务器!') return mw.returnJson(True, '正在重启服务器!')
##### ----- end ----- ### ##### ----- end ----- ###
@async @mw_async
def restartMw(self): def restartMw(self):
sleep(0.3) sleep(0.3)
# cmd = mw.getRunDir() + '/scripts/init.d/mw restart' # cmd = mw.getRunDir() + '/scripts/init.d/mw restart'
# print cmd # print cmd
mw.execShell('service mw restart') mw.execShell('service mw restart')
@async @mw_async
def restartServer(self): def restartServer(self):
if not mw.isRestart(): if not mw.isRestart():
return mw.returnJson(False, '请等待所有安装任务完成再执行!') return mw.returnJson(False, '请等待所有安装任务完成再执行!')
@ -302,7 +302,7 @@ class system_api:
memInfo['memBuffers'] - memInfo['memCached'] memInfo['memBuffers'] - memInfo['memCached']
tmp1 = memInfo['memTotal'] / 100 tmp1 = memInfo['memTotal'] / 100
return (tmp / tmp1) return (tmp / tmp1)
except Exception, ex: except Exception as ex:
return 1 return 1
def getDiskInfo(self, get=None): def getDiskInfo(self, get=None):
@ -396,7 +396,7 @@ class system_api:
shutil.rmtree(filename) shutil.rmtree(filename)
else: else:
os.remove(filename) os.remove(filename)
print '\t\033[1;32m[OK]\033[0m' print('\t\033[1;32m[OK]\033[0m')
num += 1 num += 1
total += size total += size
count += num count += num
@ -460,8 +460,8 @@ class system_api:
networkInfo['mem'] = self.getMemInfo() networkInfo['mem'] = self.getMemInfo()
return networkInfo return networkInfo
except Exception, e: except Exception as e:
print e print(e)
return None return None
def getNetWorkApi(self): def getNetWorkApi(self):
@ -621,7 +621,7 @@ class system_api:
version = json.loads(r.content) version = json.loads(r.content)
return version[0] return version[0]
except Exception as e: except Exception as e:
print 'getServerInfo', e print('getServerInfo', e)
return {} return {}
def updateServer(self, stype, version=''): def updateServer(self, stype, version=''):
@ -680,7 +680,7 @@ class system_api:
return mw.returnJson(False, '已经是最新,无需更新!') return mw.returnJson(False, '已经是最新,无需更新!')
except Exception as ex: except Exception as ex:
print 'updateServer', ex print('updateServer', ex)
return mw.returnJson(False, "连接服务器失败!") return mw.returnJson(False, "连接服务器失败!")
# 修复面板 # 修复面板

@ -75,7 +75,7 @@ class vieCode:
if not self.__inNoise: if not self.__inNoise:
return return
font = ImageFont.truetype(self.__fontPatn, int(self.__fontSize / 1.5)) 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( noiseColor = (random.randint(150, 200), random.randint(
150, 200), random.randint(150, 200)) 150, 200), random.randint(150, 200))
@ -104,9 +104,9 @@ class vieCode:
# 画曲线 # 画曲线
color = (random.randint(30, 150), random.randint( color = (random.randint(30, 150), random.randint(
30, 150), random.randint(30, 150)) 30, 150), random.randint(30, 150))
for x in xrange(xend): for x in range(xend):
if w != 0: 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 y = a * math.sin(w * x + f) + b + self.__heigth / 2
i = int(self.__fontSize / 5) i = int(self.__fontSize / 5)
while i > 0: while i > 0:
@ -120,7 +120,7 @@ class vieCode:
font = ImageFont.truetype(self.__fontPatn, self.__fontSize) font = ImageFont.truetype(self.__fontPatn, self.__fontSize)
x = 0 x = 0
# 打印字符到画板 # 打印字符到画板
for i in xrange(self.__length): for i in range(self.__length):
# 设置字体随机颜色 # 设置字体随机颜色
color = (random.randint(30, 150), random.randint( color = (random.randint(30, 150), random.randint(
30, 150), random.randint(30, 150)) 30, 150), random.randint(30, 150))

@ -0,0 +1 @@
jnuxgfkj

@ -188,24 +188,24 @@ def getLog():
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
if func == 'status': if func == 'status':
print status() print(status())
elif func == 'start': elif func == 'start':
print start() print(start())
elif func == 'stop': elif func == 'stop':
print stop() print(stop())
elif func == 'restart': elif func == 'restart':
print restart() print(restart())
elif func == 'reload': elif func == 'reload':
print reload() print(reload())
elif func == 'conf': elif func == 'conf':
print getPathFile() print(getPathFile())
elif func == 'initd_status': elif func == 'initd_status':
print initdStatus() print(initdStatus())
elif func == 'initd_install': elif func == 'initd_install':
print initdInstall() print(initdInstall())
elif func == 'initd_uninstall': elif func == 'initd_uninstall':
print initdUinstall() print(initdUinstall())
elif func == 'run_log': elif func == 'run_log':
print getLog() print(getLog())
else: else:
print 'error' print('error')

@ -98,12 +98,12 @@ def reload():
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
if func == 'status': if func == 'status':
print status() print(status())
elif func == 'start': elif func == 'start':
print start() print(start())
elif func == 'stop': elif func == 'stop':
print stop() print(stop())
elif func == 'restart': elif func == 'restart':
print restart() print(restart())
elif func == 'reload': elif func == 'reload':
print reload() print(reload())

@ -658,52 +658,52 @@ def getTotalStatistics():
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
if func == 'status': if func == 'status':
print status() print(status())
elif func == 'start': elif func == 'start':
print start() print(start())
elif func == 'stop': elif func == 'stop':
print stop() print(stop())
elif func == 'restart': elif func == 'restart':
print restart() print(restart())
elif func == 'reload': elif func == 'reload':
print reload() print(reload())
elif func == 'initd_status': elif func == 'initd_status':
print initdStatus() print(initdStatus())
elif func == 'initd_install': elif func == 'initd_install':
print initdInstall() print(initdInstall())
elif func == 'initd_uninstall': elif func == 'initd_uninstall':
print initdUinstall() print(initdUinstall())
elif func == 'csvn_edit': elif func == 'csvn_edit':
print csvnEdit() print(csvnEdit())
elif func == 'user_list': elif func == 'user_list':
print userList() print(userList())
elif func == 'user_add': elif func == 'user_add':
print userAdd() print(userAdd())
elif func == 'user_del': elif func == 'user_del':
print userDel() print(userDel())
elif func == 'project_list': elif func == 'project_list':
print projectList() print(projectList())
elif func == 'project_del': elif func == 'project_del':
print projectDel() print(projectDel())
elif func == 'project_add': elif func == 'project_add':
print projectAdd() print(projectAdd())
elif func == 'project_acl_list': elif func == 'project_acl_list':
print projectAclList() print(projectAclList())
elif func == 'project_acl_add': elif func == 'project_acl_add':
print projectAclAdd() print(projectAclAdd())
elif func == 'project_acl_del': elif func == 'project_acl_del':
print projectAclDel() print(projectAclDel())
elif func == 'project_acl_set': elif func == 'project_acl_set':
print projectAclSet() print(projectAclSet())
elif func == 'project_script_load': elif func == 'project_script_load':
print projectScriptLoad() print(projectScriptLoad())
elif func == 'project_script_unload': elif func == 'project_script_unload':
print projectScriptUnload() print(projectScriptUnload())
elif func == 'project_script_edit': elif func == 'project_script_edit':
print projectScriptEdit() print(projectScriptEdit())
elif func == 'project_script_debug': elif func == 'project_script_debug':
print projectScriptDebug() print(projectScriptDebug())
elif func == 'get_total_statistics': elif func == 'get_total_statistics':
print getTotalStatistics() print(getTotalStatistics())
else: else:
print 'fail' print('fail')

@ -637,50 +637,50 @@ def getTotalStatistics():
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
if func == 'status': if func == 'status':
print status() print(status())
elif func == 'start': elif func == 'start':
print start() print(start())
elif func == 'stop': elif func == 'stop':
print stop() print(stop())
elif func == 'restart': elif func == 'restart':
print restart() print(restart())
elif func == 'reload': elif func == 'reload':
print reload() print(reload())
elif func == 'initd_status': elif func == 'initd_status':
print initdStatus() print(initdStatus())
elif func == 'initd_install': elif func == 'initd_install':
print initdInstall() print(initdInstall())
elif func == 'initd_uninstall': elif func == 'initd_uninstall':
print initdUinstall() print(initdUinstall())
elif func == 'run_log': elif func == 'run_log':
print runLog() print(runLog())
elif func == 'post_receive_log': elif func == 'post_receive_log':
print postReceiveLog() print(postReceiveLog())
elif func == 'conf': elif func == 'conf':
print getConf() print(getConf())
elif func == 'init_conf': elif func == 'init_conf':
print getInitdConf() print(getInitdConf())
elif func == 'get_gogs_conf': elif func == 'get_gogs_conf':
print getGogsConf() print(getGogsConf())
elif func == 'submit_gogs_conf': elif func == 'submit_gogs_conf':
print submitGogsConf() print(submitGogsConf())
elif func == 'user_list': elif func == 'user_list':
print userList() print(userList())
elif func == 'user_project_list': elif func == 'user_project_list':
print userProjectList() print(userProjectList())
elif func == 'project_script_edit': elif func == 'project_script_edit':
print projectScriptEdit() print(projectScriptEdit())
elif func == 'project_script_load': elif func == 'project_script_load':
print projectScriptLoad() print(projectScriptLoad())
elif func == 'project_script_unload': elif func == 'project_script_unload':
print projectScriptUnload() print(projectScriptUnload())
elif func == 'project_script_debug': elif func == 'project_script_debug':
print projectScriptDebug() print(projectScriptDebug())
elif func == 'gogs_edit': elif func == 'gogs_edit':
print gogsEdit() print(gogsEdit())
elif func == 'get_rsa_public': elif func == 'get_rsa_public':
print getRsaPublic() print(getRsaPublic())
elif func == 'get_total_statistics': elif func == 'get_total_statistics':
print getTotalStatistics() print(getTotalStatistics())
else: else:
print 'fail' print('fail')

@ -172,24 +172,24 @@ def getLog():
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
if func == 'status': if func == 'status':
print status() print(status())
elif func == 'start': elif func == 'start':
print start() print(start())
elif func == 'stop': elif func == 'stop':
print stop() print(stop())
elif func == 'restart': elif func == 'restart':
print restart() print(restart())
elif func == 'reload': elif func == 'reload':
print reload() print(reload())
elif func == 'conf': elif func == 'conf':
print getPathFile() print(getPathFile())
elif func == 'initd_status': elif func == 'initd_status':
print initdStatus() print(initdStatus())
elif func == 'initd_install': elif func == 'initd_install':
print initdInstall() print(initdInstall())
elif func == 'initd_uninstall': elif func == 'initd_uninstall':
print initdUinstall() print(initdUinstall())
elif func == 'run_log': elif func == 'run_log':
print getLog() print(getLog())
else: else:
print 'error' print('error')

@ -10,12 +10,12 @@ gunicorn==19.9
gevent==21.1.2 gevent==21.1.2
gevent-websocket gevent-websocket
psutil==5.6.6 psutil==5.6.6
pillow==6.2.2
chardet==3.0.4 chardet==3.0.4
flask-sqlalchemy==2.3.2 flask-sqlalchemy==2.3.2
cryptography==3.3.2 cryptography==3.3.2
requests==2.20.0 requests==2.20.0
ConfigParser==3.5.0 ConfigParser==3.5.0
MySQL-python==1.2.5
mysql-connector-python mysql-connector-python
flask-socketio==3.0.1 flask-socketio==3.0.1
python-engineio==3.9.0 python-engineio==3.9.0

@ -135,14 +135,16 @@ def code():
import vilidate import vilidate
vie = vilidate.vieCode() vie = vilidate.vieCode()
codeImage = vie.GetCodeImage(80, 4) codeImage = vie.GetCodeImage(80, 4)
try: # try:
from cStringIO import StringIO # from cStringIO import StringIO
except: # except:
from StringIO import StringIO # from StringIO import StringIO
out = StringIO() out = io.BytesIO()
codeImage[0].save(out, "png") codeImage[0].save(out, "png")
print(codeImage[1])
session['code'] = mw.md5(''.join(codeImage[1]).lower()) session['code'] = mw.md5(''.join(codeImage[1]).lower())
img = Response(out.getvalue(), headers={'Content-Type': 'image/png'}) img = Response(out.getvalue(), headers={'Content-Type': 'image/png'})
@ -174,15 +176,21 @@ def doLogin():
username = request.form.get('username', '').strip() username = request.form.get('username', '').strip()
password = request.form.get('password', '').strip() password = request.form.get('password', '').strip()
code = request.form.get('code', '').strip() code = request.form.get('code', '').strip()
print(session)
if session.has_key('code'): # if 'code' in session:
if session['code'] != mw.md5(code): # if session['code'] != mw.md5(code):
return mw.returnJson(False, '验证码错误,请重新输入!') # return mw.returnJson(False, '验证码错误,请重新输入!')
userInfo = mw.M('users').where( userInfo = mw.M('users').where(
"id=?", (1,)).field('id,username,password').find() "id=?", (1,)).field('id,username,password').find()
print(userInfo)
print(password)
password = mw.md5(password) password = mw.md5(password)
print('md5-pass', password)
login_cache_count = 5 login_cache_count = 5
login_cache_limit = cache.get('login_cache_limit') login_cache_limit = cache.get('login_cache_limit')
filename = 'data/close.pl' filename = 'data/close.pl'

Loading…
Cancel
Save