kcws 3.49__tar.gz → 3.51__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kcws-3.49 → kcws-3.51}/PKG-INFO +2 -2
- {kcws-3.49 → kcws-3.51}/kcws/__init__.py +1 -1
- kcws-3.51/kcws/common/__init__.py +5 -0
- {kcws-3.49 → kcws-3.51}/kcws/common/autoload.py +289 -162
- {kcws-3.49 → kcws-3.51}/kcws.egg-info/PKG-INFO +2 -2
- kcws-3.49/kcws/common/__init__.py +0 -5
- {kcws-3.49 → kcws-3.51}/kcws/Events.py +0 -0
- {kcws-3.49 → kcws-3.51}/kcws/app.py +0 -0
- {kcws-3.49 → kcws-3.51}/kcws/common/globals.py +0 -0
- {kcws-3.49 → kcws-3.51}/kcws/common/request.py +0 -0
- {kcws-3.49 → kcws-3.51}/kcws/config/__init__.py +0 -0
- {kcws-3.49 → kcws-3.51}/kcws/kcws.py +0 -0
- {kcws-3.49 → kcws-3.51}/kcws.egg-info/SOURCES.txt +0 -0
- {kcws-3.49 → kcws-3.51}/kcws.egg-info/dependency_links.txt +0 -0
- {kcws-3.49 → kcws-3.51}/kcws.egg-info/entry_points.txt +0 -0
- {kcws-3.49 → kcws-3.51}/kcws.egg-info/requires.txt +0 -0
- {kcws-3.49 → kcws-3.51}/kcws.egg-info/top_level.txt +0 -0
- {kcws-3.49 → kcws-3.51}/setup.cfg +0 -0
- {kcws-3.49 → kcws-3.51}/setup.py +0 -0
{kcws-3.49 → kcws-3.51}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.2
|
|
2
2
|
Name: kcws
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.51
|
|
4
4
|
Summary: kcwebs作为web开发而设计的高性能框架
|
|
5
5
|
Home-page: https://docs.kwebapp.cn/index/index/2
|
|
6
6
|
Author: 百里-坤坤
|
|
@@ -9,5 +9,5 @@ Maintainer: 坤坤
|
|
|
9
9
|
Maintainer-email: fk1402936534@qq.com
|
|
10
10
|
License: MIT License
|
|
11
11
|
Description: kcwebs作为web开发而设计的高性能框架,采用全新的架构思想,注重易用性。遵循MIT开源许可协议发布,意味着个人和企业可以免费使用kcwebs,甚至允许把你基于kcwebs开发的应用开源或商业产品发布或销售。完整文档请访问:https://docs.kwebapp.cn/index/index/2
|
|
12
|
-
Keywords: kcws3.
|
|
12
|
+
Keywords: kcws3.51
|
|
13
13
|
Platform: UNKNOWN
|
|
@@ -1,8 +1,57 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
import time,hashlib,json,re,os,platform,shutil,requests,importlib,traceback,tarfile,zipfile,signal,psutil
|
|
2
|
+
import time,hashlib,json,re,os,platform,shutil,requests,importlib,traceback,tarfile,zipfile,signal,psutil,random
|
|
3
3
|
from kcws import config
|
|
4
4
|
from . import globals
|
|
5
5
|
import subprocess
|
|
6
|
+
def is_index(params,index):
|
|
7
|
+
"""判断列表或字典里的索引是否存在
|
|
8
|
+
|
|
9
|
+
params 列表或字典
|
|
10
|
+
|
|
11
|
+
index 索引值
|
|
12
|
+
|
|
13
|
+
return Boolean类型
|
|
14
|
+
"""
|
|
15
|
+
try:
|
|
16
|
+
params[index]
|
|
17
|
+
except KeyError:
|
|
18
|
+
return False
|
|
19
|
+
except IndexError:
|
|
20
|
+
return False
|
|
21
|
+
else:
|
|
22
|
+
return True
|
|
23
|
+
def randoms(lens=6,types=1):
|
|
24
|
+
"""生成随机字符串
|
|
25
|
+
|
|
26
|
+
lens 长度
|
|
27
|
+
|
|
28
|
+
types 1数字 2字母 3字母加数字
|
|
29
|
+
"""
|
|
30
|
+
strs="0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM,!@#$%^&*()_+=-;',./:<>?"
|
|
31
|
+
if types==1:
|
|
32
|
+
strs="0123456789"
|
|
33
|
+
elif types==2:
|
|
34
|
+
strs="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
|
|
35
|
+
elif types==3:
|
|
36
|
+
strs="0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
|
|
37
|
+
k=''
|
|
38
|
+
i=0
|
|
39
|
+
while i < lens:
|
|
40
|
+
k+=random.choice(strs)
|
|
41
|
+
i+=1
|
|
42
|
+
return k
|
|
43
|
+
|
|
44
|
+
def timestampToDate(times,format="%Y-%m-%d %H:%M:%S"):
|
|
45
|
+
"""时间戳转换时间
|
|
46
|
+
|
|
47
|
+
times 10位时间戳
|
|
48
|
+
|
|
49
|
+
format 日期格式 如%Y-%m-%d %H:%M:%S
|
|
50
|
+
"""
|
|
51
|
+
timeArray = time.localtime(int(times))
|
|
52
|
+
return time.strftime(format.encode('unicode-escape').decode(),timeArray).encode().decode('unicode-escape')
|
|
53
|
+
|
|
54
|
+
|
|
6
55
|
def get_pid_by_port(port):
|
|
7
56
|
"""获取使用指定端口使用的进程号pid"""
|
|
8
57
|
pid=[]
|
|
@@ -18,164 +67,6 @@ def get_pid_by_port(port):
|
|
|
18
67
|
else:
|
|
19
68
|
raise Exception(strs)
|
|
20
69
|
return pid
|
|
21
|
-
class kcwszip:
|
|
22
|
-
def __clean_filename(filename):
|
|
23
|
-
# 移除或替换非法字符
|
|
24
|
-
filename =re.sub(r'[<>:"/\\|?*]', '', filename)
|
|
25
|
-
filename=filename.replace('\t','')
|
|
26
|
-
# print('filenamefilenamefilenamefilename',filename)
|
|
27
|
-
return filename
|
|
28
|
-
def packzip(src,dst):
|
|
29
|
-
"压缩"
|
|
30
|
-
filelist = []
|
|
31
|
-
if os.path.isfile(src):
|
|
32
|
-
filelist.append(src)
|
|
33
|
-
for root, dirs, files in os.walk(src):
|
|
34
|
-
for name in files:
|
|
35
|
-
filelist.append(os.path.join(root, name))
|
|
36
|
-
zf = zipfile.ZipFile(dst, "w", zipfile.zlib.DEFLATED)
|
|
37
|
-
for tar in filelist:
|
|
38
|
-
arcname = tar[len(src):]
|
|
39
|
-
zf.write(tar,arcname)
|
|
40
|
-
zf.close()
|
|
41
|
-
def unzip_file(dst, src,all=True):
|
|
42
|
-
"解压"
|
|
43
|
-
if all:
|
|
44
|
-
zf = zipfile.ZipFile(dst)
|
|
45
|
-
zf.extractall(src)
|
|
46
|
-
zf.close()
|
|
47
|
-
else:
|
|
48
|
-
zip_ref=zipfile.ZipFile(dst)
|
|
49
|
-
for item in zip_ref.infolist():
|
|
50
|
-
zip_ref.extract(item, src)
|
|
51
|
-
zip_ref.close()
|
|
52
|
-
def unzip(filename):
|
|
53
|
-
"解压到文件所在目录"
|
|
54
|
-
diswjj=''
|
|
55
|
-
tarr=filename.split('.')
|
|
56
|
-
i=0
|
|
57
|
-
while i<len(tarr)-1:
|
|
58
|
-
if i<=len(tarr)-3:
|
|
59
|
-
diswjj+=tarr[i]+'.'
|
|
60
|
-
else:
|
|
61
|
-
diswjj+=tarr[i]
|
|
62
|
-
i+=1
|
|
63
|
-
# if not os.path.exists(diswjj):
|
|
64
|
-
# os.makedirs(diswjj,exist_ok=True)
|
|
65
|
-
try:
|
|
66
|
-
zip_ref=zipfile.ZipFile(filename, 'r')
|
|
67
|
-
for item in zip_ref.infolist():
|
|
68
|
-
try:
|
|
69
|
-
item.filename = item.filename.encode('cp437').decode('gbk')
|
|
70
|
-
except:pass
|
|
71
|
-
try:
|
|
72
|
-
item.filename = item.filename.replace('\t','').replace('\n','').replace('\b','')
|
|
73
|
-
except:pass
|
|
74
|
-
# print("item.filename",item.filename)
|
|
75
|
-
try:
|
|
76
|
-
zip_ref.extract(item, diswjj)
|
|
77
|
-
except Exception as e:
|
|
78
|
-
stre=str(e)
|
|
79
|
-
if 'Bad CRC-32 for fil' in stre:#文件损坏
|
|
80
|
-
print('压缩文件文件损坏',stre)
|
|
81
|
-
pass
|
|
82
|
-
elif '[Errno 2] No such file or directory: ' in stre:
|
|
83
|
-
print('不是有效文件',stre)
|
|
84
|
-
pass
|
|
85
|
-
elif '[WinError 3] 系统找不到指定的路径' in stre:
|
|
86
|
-
print('系统找不到指定的路径',stre)
|
|
87
|
-
pass
|
|
88
|
-
elif '文件名或扩展名太长' in stre:
|
|
89
|
-
if os.path.exists(diswjj):
|
|
90
|
-
try:
|
|
91
|
-
shutil.rmtree(diswjj)
|
|
92
|
-
except:pass
|
|
93
|
-
try:
|
|
94
|
-
zip_ref.close()
|
|
95
|
-
except:pass
|
|
96
|
-
if os.name == 'nt':
|
|
97
|
-
if not os.path.exists("c:/temp"):
|
|
98
|
-
os.makedirs("c:/temp", exist_ok=True)
|
|
99
|
-
newspath="c:/temp/"+md5(filename)
|
|
100
|
-
print('文件名或扩展名太长,正在复制到 '+newspath+' 重试')
|
|
101
|
-
tempname=newspath+'.zip'
|
|
102
|
-
if not os.path.exists(newspath):
|
|
103
|
-
os.makedirs(newspath, exist_ok=True)
|
|
104
|
-
shutil.copy(filename, tempname)
|
|
105
|
-
return kcwszip.unzip(tempname)
|
|
106
|
-
else:
|
|
107
|
-
print('stre',stre,filename)
|
|
108
|
-
raise Exception(e)
|
|
109
|
-
else:
|
|
110
|
-
if os.path.exists(diswjj):
|
|
111
|
-
try:
|
|
112
|
-
shutil.rmtree(diswjj)
|
|
113
|
-
except:pass
|
|
114
|
-
try:
|
|
115
|
-
zip_ref.close()
|
|
116
|
-
except:pass
|
|
117
|
-
print('stre',stre,filename)
|
|
118
|
-
raise Exception(e)
|
|
119
|
-
zip_ref.close()
|
|
120
|
-
except Exception as e:
|
|
121
|
-
stre=str(e)
|
|
122
|
-
print('zip解压异常',stre)
|
|
123
|
-
raise Exception(e)
|
|
124
|
-
# if 'File is not a zip file' in stre or 'Bad CRC-32 for fil' in stre:
|
|
125
|
-
# if os.path.exists(diswjj):
|
|
126
|
-
# try:
|
|
127
|
-
# shutil.rmtree(diswjj)
|
|
128
|
-
# except:pass
|
|
129
|
-
# return False
|
|
130
|
-
# else:
|
|
131
|
-
# if os.path.exists(diswjj):
|
|
132
|
-
# shutil.rmtree(diswjj)
|
|
133
|
-
# raise Exception(e)
|
|
134
|
-
#处理中文乱码
|
|
135
|
-
arr=get_file(diswjj,is_folder=False)
|
|
136
|
-
for kkk in arr:
|
|
137
|
-
new_name=kkk['path'].split('/')
|
|
138
|
-
try:
|
|
139
|
-
new_name=kkk['path'].replace(new_name[len(new_name)-1],kkk['name'].encode('cp437').decode("gbk"))
|
|
140
|
-
except:
|
|
141
|
-
# print(kkk['name'],'编码无需要解码')
|
|
142
|
-
pass
|
|
143
|
-
else:
|
|
144
|
-
try:
|
|
145
|
-
os.rename(kkk['path'], new_name)
|
|
146
|
-
except Exception as e:
|
|
147
|
-
stre=str(e)
|
|
148
|
-
if '当文件已存在时,无法创建该文件' in stre:
|
|
149
|
-
pass
|
|
150
|
-
else:
|
|
151
|
-
if os.path.exists(diswjj):
|
|
152
|
-
shutil.rmtree(diswjj)
|
|
153
|
-
raise Exception(e)
|
|
154
|
-
return diswjj
|
|
155
|
-
class kcwstar:
|
|
156
|
-
def targz(src,dst):
|
|
157
|
-
"""
|
|
158
|
-
打包目录为tar.gz
|
|
159
|
-
:param src: 需要打包的目录
|
|
160
|
-
:param dst: 压缩文件名
|
|
161
|
-
:return: bool
|
|
162
|
-
"""
|
|
163
|
-
with tarfile.open(dst, "w:gz") as tar:
|
|
164
|
-
tar.add(src, arcname=os.path.basename(src))
|
|
165
|
-
return True
|
|
166
|
-
def untar(dst, src):
|
|
167
|
-
"""
|
|
168
|
-
解压tar.gz文件
|
|
169
|
-
:param dst: 压缩文件名
|
|
170
|
-
:param src: 解压后的存放路径
|
|
171
|
-
:return: bool
|
|
172
|
-
"""
|
|
173
|
-
try:
|
|
174
|
-
t = tarfile.open(dst)
|
|
175
|
-
t.extractall(path = src)
|
|
176
|
-
return True
|
|
177
|
-
except Exception as e:
|
|
178
|
-
return False
|
|
179
70
|
|
|
180
71
|
def get_file(folder='./',is_folder=True,suffix="*",lists=[],append=False):
|
|
181
72
|
"""获取文件夹下所有文件夹和文件
|
|
@@ -328,7 +219,7 @@ def kill_pid(pid):
|
|
|
328
219
|
pid 进程号
|
|
329
220
|
"""
|
|
330
221
|
if pid:
|
|
331
|
-
for i in range(
|
|
222
|
+
for i in range(60):
|
|
332
223
|
if 'Linux' in get_sysinfo()['platform']:
|
|
333
224
|
os.system("kill -9 "+str(pid))
|
|
334
225
|
else:
|
|
@@ -339,8 +230,8 @@ def kill_pid(pid):
|
|
|
339
230
|
return True
|
|
340
231
|
else:
|
|
341
232
|
time.sleep(0.1)
|
|
342
|
-
if i>60:
|
|
343
|
-
|
|
233
|
+
# if i>60:
|
|
234
|
+
# raise Exception('kill_pid error:pid='+str(pid))
|
|
344
235
|
return True
|
|
345
236
|
def kill_route_cli(route):
|
|
346
237
|
"""通过路由结束进程
|
|
@@ -402,6 +293,242 @@ def get_sysinfo():
|
|
|
402
293
|
# platform.python_version()
|
|
403
294
|
# platform.python_version_tuple()
|
|
404
295
|
return sysinfo
|
|
296
|
+
|
|
297
|
+
class kcwszip:
|
|
298
|
+
def __clean_filename(filename):
|
|
299
|
+
# 移除或替换非法字符
|
|
300
|
+
filename =re.sub(r'[<>:"/\\|?*]', '', filename)
|
|
301
|
+
filename=filename.replace('\t','')
|
|
302
|
+
# print('filenamefilenamefilenamefilename',filename)
|
|
303
|
+
return filename
|
|
304
|
+
def packzip(src,dst):
|
|
305
|
+
"压缩"
|
|
306
|
+
filelist = []
|
|
307
|
+
if os.path.isfile(src):
|
|
308
|
+
filelist.append(src)
|
|
309
|
+
for root, dirs, files in os.walk(src):
|
|
310
|
+
for name in files:
|
|
311
|
+
filelist.append(os.path.join(root, name))
|
|
312
|
+
zf = zipfile.ZipFile(dst, "w", zipfile.zlib.DEFLATED)
|
|
313
|
+
for tar in filelist:
|
|
314
|
+
arcname = tar[len(src):]
|
|
315
|
+
zf.write(tar,arcname)
|
|
316
|
+
zf.close()
|
|
317
|
+
def unzip_file(dst, src,all=True):
|
|
318
|
+
"解压"
|
|
319
|
+
if all:
|
|
320
|
+
zf = zipfile.ZipFile(dst)
|
|
321
|
+
zf.extractall(src)
|
|
322
|
+
zf.close()
|
|
323
|
+
else:
|
|
324
|
+
zip_ref=zipfile.ZipFile(dst)
|
|
325
|
+
for item in zip_ref.infolist():
|
|
326
|
+
zip_ref.extract(item, src)
|
|
327
|
+
zip_ref.close()
|
|
328
|
+
def unzip(filename):
|
|
329
|
+
"解压到文件所在目录"
|
|
330
|
+
diswjj=''
|
|
331
|
+
tarr=filename.split('.')
|
|
332
|
+
i=0
|
|
333
|
+
while i<len(tarr)-1:
|
|
334
|
+
if i<=len(tarr)-3:
|
|
335
|
+
diswjj+=tarr[i]+'.'
|
|
336
|
+
else:
|
|
337
|
+
diswjj+=tarr[i]
|
|
338
|
+
i+=1
|
|
339
|
+
# if not os.path.exists(diswjj):
|
|
340
|
+
# os.makedirs(diswjj,exist_ok=True)
|
|
341
|
+
try:
|
|
342
|
+
zip_ref=zipfile.ZipFile(filename, 'r')
|
|
343
|
+
for item in zip_ref.infolist():
|
|
344
|
+
try:
|
|
345
|
+
item.filename = item.filename.encode('cp437').decode('gbk')
|
|
346
|
+
except:pass
|
|
347
|
+
try:
|
|
348
|
+
item.filename = item.filename.replace('\t','').replace('\n','').replace('\b','')
|
|
349
|
+
except:pass
|
|
350
|
+
# print("item.filename",item.filename)
|
|
351
|
+
try:
|
|
352
|
+
zip_ref.extract(item, diswjj)
|
|
353
|
+
except Exception as e:
|
|
354
|
+
stre=str(e)
|
|
355
|
+
if 'Bad CRC-32 for fil' in stre:#文件损坏
|
|
356
|
+
print('压缩文件文件损坏',stre)
|
|
357
|
+
pass
|
|
358
|
+
elif '[Errno 2] No such file or directory: ' in stre:
|
|
359
|
+
print('不是有效文件',stre)
|
|
360
|
+
pass
|
|
361
|
+
elif '[WinError 3] 系统找不到指定的路径' in stre:
|
|
362
|
+
print('系统找不到指定的路径',stre)
|
|
363
|
+
pass
|
|
364
|
+
elif '文件名或扩展名太长' in stre:
|
|
365
|
+
if os.path.exists(diswjj):
|
|
366
|
+
try:
|
|
367
|
+
shutil.rmtree(diswjj)
|
|
368
|
+
except:pass
|
|
369
|
+
try:
|
|
370
|
+
zip_ref.close()
|
|
371
|
+
except:pass
|
|
372
|
+
if os.name == 'nt':
|
|
373
|
+
if not os.path.exists("c:/temp"):
|
|
374
|
+
os.makedirs("c:/temp", exist_ok=True)
|
|
375
|
+
newspath="c:/temp/"+md5(filename)
|
|
376
|
+
print('文件名或扩展名太长,正在复制到 '+newspath+' 重试')
|
|
377
|
+
tempname=newspath+'.zip'
|
|
378
|
+
if not os.path.exists(newspath):
|
|
379
|
+
os.makedirs(newspath, exist_ok=True)
|
|
380
|
+
shutil.copy(filename, tempname)
|
|
381
|
+
return kcwszip.unzip(tempname)
|
|
382
|
+
else:
|
|
383
|
+
print('stre',stre,filename)
|
|
384
|
+
raise Exception(e)
|
|
385
|
+
else:
|
|
386
|
+
if os.path.exists(diswjj):
|
|
387
|
+
try:
|
|
388
|
+
shutil.rmtree(diswjj)
|
|
389
|
+
except:pass
|
|
390
|
+
try:
|
|
391
|
+
zip_ref.close()
|
|
392
|
+
except:pass
|
|
393
|
+
print('stre',stre,filename)
|
|
394
|
+
raise Exception(e)
|
|
395
|
+
zip_ref.close()
|
|
396
|
+
except Exception as e:
|
|
397
|
+
stre=str(e)
|
|
398
|
+
print('zip解压异常',stre)
|
|
399
|
+
raise Exception(e)
|
|
400
|
+
# if 'File is not a zip file' in stre or 'Bad CRC-32 for fil' in stre:
|
|
401
|
+
# if os.path.exists(diswjj):
|
|
402
|
+
# try:
|
|
403
|
+
# shutil.rmtree(diswjj)
|
|
404
|
+
# except:pass
|
|
405
|
+
# return False
|
|
406
|
+
# else:
|
|
407
|
+
# if os.path.exists(diswjj):
|
|
408
|
+
# shutil.rmtree(diswjj)
|
|
409
|
+
# raise Exception(e)
|
|
410
|
+
#处理中文乱码
|
|
411
|
+
arr=get_file(diswjj,is_folder=False)
|
|
412
|
+
for kkk in arr:
|
|
413
|
+
new_name=kkk['path'].split('/')
|
|
414
|
+
try:
|
|
415
|
+
new_name=kkk['path'].replace(new_name[len(new_name)-1],kkk['name'].encode('cp437').decode("gbk"))
|
|
416
|
+
except:
|
|
417
|
+
# print(kkk['name'],'编码无需要解码')
|
|
418
|
+
pass
|
|
419
|
+
else:
|
|
420
|
+
try:
|
|
421
|
+
os.rename(kkk['path'], new_name)
|
|
422
|
+
except Exception as e:
|
|
423
|
+
stre=str(e)
|
|
424
|
+
if '当文件已存在时,无法创建该文件' in stre:
|
|
425
|
+
pass
|
|
426
|
+
else:
|
|
427
|
+
if os.path.exists(diswjj):
|
|
428
|
+
shutil.rmtree(diswjj)
|
|
429
|
+
raise Exception(e)
|
|
430
|
+
return diswjj
|
|
431
|
+
class kcwstar:
|
|
432
|
+
def targz(src,dst):
|
|
433
|
+
"""
|
|
434
|
+
打包目录为tar.gz
|
|
435
|
+
:param src: 需要打包的目录
|
|
436
|
+
:param dst: 压缩文件名
|
|
437
|
+
:return: bool
|
|
438
|
+
"""
|
|
439
|
+
with tarfile.open(dst, "w:gz") as tar:
|
|
440
|
+
tar.add(src, arcname=os.path.basename(src))
|
|
441
|
+
return True
|
|
442
|
+
def untar(dst, src):
|
|
443
|
+
"""
|
|
444
|
+
解压tar.gz文件
|
|
445
|
+
:param dst: 压缩文件名
|
|
446
|
+
:param src: 解压后的存放路径
|
|
447
|
+
:return: bool
|
|
448
|
+
"""
|
|
449
|
+
try:
|
|
450
|
+
t = tarfile.open(dst)
|
|
451
|
+
t.extractall(path = src)
|
|
452
|
+
return True
|
|
453
|
+
except Exception as e:
|
|
454
|
+
return False
|
|
455
|
+
|
|
456
|
+
class kcwsign:
|
|
457
|
+
verifres={}
|
|
458
|
+
def verifsign(params,validity=30):
|
|
459
|
+
"""验证签名
|
|
460
|
+
|
|
461
|
+
params 验证的参数
|
|
462
|
+
|
|
463
|
+
validity 时间戳超过多少秒失败
|
|
464
|
+
"""
|
|
465
|
+
kcwsign.verifres={}
|
|
466
|
+
if not is_index(params,'time') or not is_index(params,'rands') or not is_index(params,'sign'):
|
|
467
|
+
kcwsign.verifres['code']=-16
|
|
468
|
+
kcwsign.verifres['msg']='缺少验证参数'
|
|
469
|
+
return False
|
|
470
|
+
if not params['time'] or not params['rands'] or not params['sign']:
|
|
471
|
+
kcwsign.verifres['code']=-16
|
|
472
|
+
kcwsign.verifres['msg']='验证参数不存在'
|
|
473
|
+
return False
|
|
474
|
+
sign=params['sign']
|
|
475
|
+
del params['sign']
|
|
476
|
+
sjc=int(time.time())-int(params['time'])
|
|
477
|
+
if(sjc>validity or sjc<-validity):
|
|
478
|
+
kcwsign.verifres['code']=-14
|
|
479
|
+
kcwsign.verifres['msg']='时间错误,请调整设备时间,您的设备时间是:'+timestampToDate(params['time'])
|
|
480
|
+
return False
|
|
481
|
+
mysign=kcwsign.getsign(params)
|
|
482
|
+
if mysign==sign:
|
|
483
|
+
kcwsign.verifres['code']=1
|
|
484
|
+
kcwsign.verifres['msg']='验证成功'
|
|
485
|
+
return True
|
|
486
|
+
else:
|
|
487
|
+
if is_index(params,'appkey'):
|
|
488
|
+
params['appkey']='开发者提供的appkey'
|
|
489
|
+
if is_index(params,'paympassword'):
|
|
490
|
+
params['paympassword']='支付密码'
|
|
491
|
+
if is_index(params,'paypwd'):
|
|
492
|
+
params['paypwd']='支付密码'
|
|
493
|
+
if is_index(params,'password'):
|
|
494
|
+
params['password']='密码'
|
|
495
|
+
content=kcwsign.getSignContent(params)
|
|
496
|
+
kcwsign.verifres['code']=-15
|
|
497
|
+
kcwsign.verifres['msg']='签名错误,签名内容可参考:md5('+content+')'
|
|
498
|
+
return False
|
|
499
|
+
def getsign(params):
|
|
500
|
+
"""获取签名"""
|
|
501
|
+
if is_index(params,'sign'):
|
|
502
|
+
del params['sign']
|
|
503
|
+
content=kcwsign.getSignContent(params)
|
|
504
|
+
return md5(content)
|
|
505
|
+
def exsignpra(params):
|
|
506
|
+
"生成签名参数"
|
|
507
|
+
params['time']=times()
|
|
508
|
+
params['rands']=randoms()
|
|
509
|
+
params['sign']=kcwsign.getsign(params)
|
|
510
|
+
return params
|
|
511
|
+
def getSignContent(params):
|
|
512
|
+
"字典排序"
|
|
513
|
+
param={}
|
|
514
|
+
for i in sorted (params):
|
|
515
|
+
param[i]=params[i]
|
|
516
|
+
i=0
|
|
517
|
+
strs=""
|
|
518
|
+
for k in param:
|
|
519
|
+
if k:
|
|
520
|
+
if isinstance(k,dict):
|
|
521
|
+
k=json_encode(k)
|
|
522
|
+
k=k.replace('"', '')
|
|
523
|
+
k=k.replace("'", '')
|
|
524
|
+
if param[k]:
|
|
525
|
+
if i==0:
|
|
526
|
+
strs+=str(k)+"="+str(param[k])
|
|
527
|
+
else:
|
|
528
|
+
strs+="&"+str(k)+"="+str(param[k])
|
|
529
|
+
i+=1
|
|
530
|
+
return strs
|
|
531
|
+
|
|
405
532
|
class create:
|
|
406
533
|
project=''
|
|
407
534
|
appname=None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.2
|
|
2
2
|
Name: kcws
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.51
|
|
4
4
|
Summary: kcwebs作为web开发而设计的高性能框架
|
|
5
5
|
Home-page: https://docs.kwebapp.cn/index/index/2
|
|
6
6
|
Author: 百里-坤坤
|
|
@@ -9,5 +9,5 @@ Maintainer: 坤坤
|
|
|
9
9
|
Maintainer-email: fk1402936534@qq.com
|
|
10
10
|
License: MIT License
|
|
11
11
|
Description: kcwebs作为web开发而设计的高性能框架,采用全新的架构思想,注重易用性。遵循MIT开源许可协议发布,意味着个人和企业可以免费使用kcwebs,甚至允许把你基于kcwebs开发的应用开源或商业产品发布或销售。完整文档请访问:https://docs.kwebapp.cn/index/index/2
|
|
12
|
-
Keywords: kcws3.
|
|
12
|
+
Keywords: kcws3.51
|
|
13
13
|
Platform: UNKNOWN
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kcws-3.49 → kcws-3.51}/setup.py
RENAMED
|
File without changes
|