kcwapi 3.54__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.
kcwapi-3.54/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 1.2
2
+ Name: kcwapi
3
+ Version: 3.54
4
+ Summary: kcwapi
5
+ Home-page: https://docs.kwebapp.cn/index/index/2
6
+ Author: 百里-坤坤
7
+ Author-email: kcwebs@kwebapp.cn
8
+ Maintainer: 坤坤
9
+ Maintainer-email: 1402936534@qq.com
10
+ License: MIT License
11
+ Description: kcwapi
12
+ Keywords: kcwapi3.54
13
+ Platform: UNKNOWN
@@ -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 'kcwapi.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 'kcwapi'==self.command[0] or 'kcwebs'==self.command[0] or 'kcwebp'==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文件
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ __version__ = '3.54'
3
+ try:
4
+ from .app import web
5
+ except:pass
6
+ # print('警告:from .app import web导入失败')
7
+ # from . import config
8
+ kcwsinfo={}
9
+ kcwsinfo['name']='kcwapi' #项目的名称
10
+ kcwsinfo['version']=__version__ #项目版本
11
+ kcwsinfo['description']='kcwapi' #项目的简单描述
12
+ kcwsinfo['long_description']='kcwapi' #项目详细描述
13
+ kcwsinfo['license']='MIT License' #开源协议 mit开源
14
+ kcwsinfo['url']='https://docs.kwebapp.cn/index/index/2'
15
+ kcwsinfo['author']='百里-坤坤' #名字
16
+ kcwsinfo['author_email']='kcwebs@kwebapp.cn' #邮件地址
17
+ kcwsinfo['maintainer']='坤坤' #维护人员的名字
18
+ kcwsinfo['maintainer_email']='1402936534@qq.com' #维护人员的邮件地址