kcws 1.0__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-1.0/PKG-INFO +13 -0
- kcws-1.0/README.md +8 -0
- kcws-1.0/kcws/Events.py +75 -0
- kcws-1.0/kcws/__init__.py +4 -0
- kcws-1.0/kcws/app.py +1042 -0
- kcws-1.0/kcws/common/__init__.py +5 -0
- kcws-1.0/kcws/common/autoload.py +835 -0
- kcws-1.0/kcws/common/globals.py +9 -0
- kcws-1.0/kcws/common/request.py +156 -0
- kcws-1.0/kcws/config/__init__.py +52 -0
- kcws-1.0/kcws/kcws.py +406 -0
- kcws-1.0/kcws.egg-info/PKG-INFO +13 -0
- kcws-1.0/kcws.egg-info/SOURCES.txt +17 -0
- kcws-1.0/kcws.egg-info/dependency_links.txt +1 -0
- kcws-1.0/kcws.egg-info/entry_points.txt +3 -0
- kcws-1.0/kcws.egg-info/requires.txt +5 -0
- kcws-1.0/kcws.egg-info/top_level.txt +4 -0
- kcws-1.0/setup.cfg +4 -0
- kcws-1.0/setup.py +72 -0
kcws-1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 1.2
|
|
2
|
+
Name: kcws
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: 超轻量级http框架
|
|
5
|
+
Home-page: https://docs.kwebapp.cn/index/index/1
|
|
6
|
+
Author: 百里-坤坤
|
|
7
|
+
Author-email: kcwebs@kwebapp.cn
|
|
8
|
+
Maintainer: 坤坤
|
|
9
|
+
Maintainer-email: fk1402936534@qq.com
|
|
10
|
+
License: MIT License
|
|
11
|
+
Description: kcws是一个由kcwebs抽象出来的超轻量级http框架
|
|
12
|
+
Keywords: kcws1.0
|
|
13
|
+
Platform: UNKNOWN
|
kcws-1.0/README.md
ADDED
kcws-1.0/kcws/Events.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os, time, subprocess,psutil
|
|
3
|
+
from watchdog.observers import Observer
|
|
4
|
+
from watchdog.events import FileSystemEventHandler
|
|
5
|
+
class MyFileSystemEventHander(FileSystemEventHandler):
|
|
6
|
+
__eventgtimexz=0
|
|
7
|
+
def __init__(self, fn):
|
|
8
|
+
super(MyFileSystemEventHander, self).__init__()
|
|
9
|
+
self.restart = fn
|
|
10
|
+
|
|
11
|
+
def on_any_event(self, event):
|
|
12
|
+
if '.py' in event.src_path and event.src_path.endswith('.py'):
|
|
13
|
+
global eventgtimexz
|
|
14
|
+
if time.time()-self.__eventgtimexz > 0.5:
|
|
15
|
+
self.__eventgtimexz=time.time()
|
|
16
|
+
# print('* 更新文件:%s' % event.src_path,event.event_type)
|
|
17
|
+
if event.event_type=='modified':
|
|
18
|
+
if 'controller\__init__.py' in event.src_path or 'app\__init__.py' in event.src_path:
|
|
19
|
+
time.sleep(10)
|
|
20
|
+
pass
|
|
21
|
+
else:
|
|
22
|
+
self.restart()
|
|
23
|
+
class Events:
|
|
24
|
+
command = ['echo', 'ok']
|
|
25
|
+
process = None
|
|
26
|
+
def __init__(self,argv):
|
|
27
|
+
# print('event1',argv)
|
|
28
|
+
# if ('--server' not in argv and 'python' not in argv[0]) or 'kcws.py' in argv:
|
|
29
|
+
# print('event2',argv)
|
|
30
|
+
# argv.insert(0, 'python')
|
|
31
|
+
self.command = argv
|
|
32
|
+
paths = os.path.abspath('.')
|
|
33
|
+
# print(paths)
|
|
34
|
+
self.start_watch(paths)
|
|
35
|
+
|
|
36
|
+
def kill_process(self):
|
|
37
|
+
"关闭"
|
|
38
|
+
if self.process:
|
|
39
|
+
if 'kcws'==self.command[0] or 'kcwebs'==self.command[0] or 'kcwebps2'==self.command[0]:
|
|
40
|
+
try:
|
|
41
|
+
process = psutil.Process(self.process.pid)
|
|
42
|
+
except:pass
|
|
43
|
+
else:
|
|
44
|
+
for proc in process.children(recursive=True):
|
|
45
|
+
proc.kill()
|
|
46
|
+
proc.kill()
|
|
47
|
+
else:
|
|
48
|
+
self.process.kill()
|
|
49
|
+
self.process.wait()
|
|
50
|
+
self.process = None
|
|
51
|
+
def start_process(self):
|
|
52
|
+
"启动"
|
|
53
|
+
self.process = subprocess.Popen(self.command)
|
|
54
|
+
def restart_process(self):
|
|
55
|
+
"重启"
|
|
56
|
+
|
|
57
|
+
self.kill_process()
|
|
58
|
+
time.sleep(0.1)
|
|
59
|
+
self.start_process()
|
|
60
|
+
|
|
61
|
+
def start_watch(self,path):
|
|
62
|
+
"执行"
|
|
63
|
+
observer = Observer()
|
|
64
|
+
observer.schedule(MyFileSystemEventHander(self.restart_process), path, recursive=True)
|
|
65
|
+
observer.start()
|
|
66
|
+
self.start_process()
|
|
67
|
+
try:
|
|
68
|
+
while True:
|
|
69
|
+
time.sleep(0.1)
|
|
70
|
+
except KeyboardInterrupt as e:
|
|
71
|
+
self.kill_process()
|
|
72
|
+
# observer.stop()
|
|
73
|
+
# observer.join()
|
|
74
|
+
|
|
75
|
+
# Events(['server.py']) #执行server.py文件
|