kunapi 1.3__tar.gz → 1.5__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.
Files changed (35) hide show
  1. {kunapi-1.3 → kunapi-1.5}/PKG-INFO +2 -2
  2. {kunapi-1.3 → kunapi-1.5}/kunapi/Events.py +1 -6
  3. {kunapi-1.3 → kunapi-1.5}/kunapi/__init__.py +1 -1
  4. {kunapi-1.3 → kunapi-1.5}/kunapi/app.py +65 -77
  5. {kunapi-1.3 → kunapi-1.5}/kunapi/common/autoload.py +0 -68
  6. {kunapi-1.3 → kunapi-1.5}/kunapi/kunapi.py +57 -67
  7. {kunapi-1.3 → kunapi-1.5}/kunapi.egg-info/PKG-INFO +2 -2
  8. {kunapi-1.3 → kunapi-1.5}/kunapi.egg-info/SOURCES.txt +0 -24
  9. {kunapi-1.3 → kunapi-1.5}/kunapi.egg-info/requires.txt +1 -0
  10. {kunapi-1.3 → kunapi-1.5}/setup.py +1 -1
  11. kunapi-1.3/kunapi/tempfile/kunapi/app/__init__.py +0 -3
  12. kunapi-1.3/kunapi/tempfile/kunapi/server.py +0 -13
  13. {kunapi-1.3 → kunapi-1.5}/kunapi/common/__init__.py +0 -0
  14. {kunapi-1.3 → kunapi-1.5}/kunapi/common/globals.py +0 -0
  15. {kunapi-1.3 → kunapi-1.5}/kunapi/common/request.py +0 -0
  16. {kunapi-1.3 → kunapi-1.5}/kunapi/config/__init__.py +0 -0
  17. {kunapi-1.3/kunapi/tempfile → kunapi-1.5/kunapi/tempfile/kunapi/app}/__init__.py +0 -0
  18. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/common/__init__.py +0 -0
  19. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/common/autoload.py +0 -0
  20. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/common/model.py +0 -0
  21. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/config/__init__.py +0 -0
  22. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/config/app.py +0 -0
  23. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/__init__.py +0 -0
  24. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/common/__init__.py +0 -0
  25. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/common/autoload.py +0 -0
  26. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/controller/__init__.py +0 -0
  27. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/controller/index/__init__.py +0 -0
  28. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/controller/index/common/__init__.py +0 -0
  29. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/controller/index/common/autoload.py +0 -0
  30. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/controller/index/common/model.py +0 -0
  31. {kunapi-1.3 → kunapi-1.5}/kunapi/tempfile/kunapi/app/index/controller/index/index.py +0 -0
  32. {kunapi-1.3 → kunapi-1.5}/kunapi.egg-info/dependency_links.txt +0 -0
  33. {kunapi-1.3 → kunapi-1.5}/kunapi.egg-info/entry_points.txt +0 -0
  34. {kunapi-1.3 → kunapi-1.5}/kunapi.egg-info/top_level.txt +0 -0
  35. {kunapi-1.3 → kunapi-1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: kunapi
3
- Version: 1.3
3
+ Version: 1.5
4
4
  Summary: kunapi
5
5
  Home-page: https://docs.kwebapp.cn/index/index/2
6
6
  Author: 百里-坤坤
@@ -9,5 +9,5 @@ Maintainer: 坤坤
9
9
  Maintainer-email: fengkun01@qq.com
10
10
  License: MIT License
11
11
  Description: kunapi
12
- Keywords: kunapi1.3
12
+ Keywords: kunapi1.5
13
13
  Platform: UNKNOWN
@@ -53,7 +53,6 @@ class Events:
53
53
  self.process = subprocess.Popen(self.command)
54
54
  def restart_process(self):
55
55
  "重启"
56
-
57
56
  self.kill_process()
58
57
  time.sleep(0.1)
59
58
  self.start_process()
@@ -68,8 +67,4 @@ class Events:
68
67
  while True:
69
68
  time.sleep(0.1)
70
69
  except KeyboardInterrupt as e:
71
- self.kill_process()
72
- # observer.stop()
73
- # observer.join()
74
-
75
- # Events(['server.py']) #执行server.py文件
70
+ self.kill_process()
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- __version__ = '1.3'
2
+ __version__ = '1.5'
3
3
  try:
4
4
  from .app import web
5
5
  except:pass
@@ -12,7 +12,6 @@ class web:
12
12
  self.__name=name
13
13
  self.__appname=appname
14
14
  if self.__name == '__main__' or self.__name=='kunapi.kunapi' or self.__name=='kwebs.kwebs' or self.__name=='kwebsp.kwebsp':
15
- # print("web__new__",self.__name)
16
15
  return super().__new__(self)
17
16
  else:
18
17
  def apps(env, start_response):
@@ -79,7 +78,6 @@ class web:
79
78
  pass
80
79
  else:
81
80
  body=bytes(body, encoding='utf-8')
82
- # print(env)
83
81
  start_response(status,resheader)
84
82
  return [body]
85
83
  return apps
@@ -99,25 +97,23 @@ class web:
99
97
  # self.__port=port
100
98
  import sys
101
99
  cmd=sys.argv
102
- # print('cmd',cmd)
103
100
  config.app['cli']=False
104
101
  if 'eventlog' in cmd or len(cmd)==1 or (len(cmd)>=2 and cmd[len(cmd)-1]=='server'):
105
102
  # config.app['cli']=False
106
103
  if 'kwebsp' in cmd[0]: #基于新版本4.13.32之后 kwebsp server运行
107
104
  cmd[0]='kwebsp'
108
- filename=cmd[0]
105
+ # filename=cmd[0]
109
106
  elif 'kwebs' in cmd[0]: #基于新版本4.13.32之后 kwebs server运行
110
107
  cmd[0]='kwebs'
111
- filename=cmd[0]
108
+ # filename=cmd[0]
112
109
  elif 'kunapi' in cmd[0]:
113
110
  cmd[0]='kunapi'
114
- filename=cmd[0]
115
- else: #基于老版本4.13.32之前 python server.py运行
116
- filename=cmd[0][:-3]
117
- # self.__filename=filename
111
+ # filename=cmd[0]
112
+ # else:
113
+ # filename=cmd[0][:-3]
118
114
  if self.__config.app['app_debug']:
119
115
  if 'eventlog' in cmd:
120
- self.__impl(host=host,port=port,filename=filename)
116
+ self.__impl(host=host,port=port)
121
117
  else:
122
118
  if name:
123
119
  cmd.insert(0,name)
@@ -125,7 +121,7 @@ class web:
125
121
  from . Events import Events
126
122
  Events(cmd)
127
123
  else:
128
- self.__impl(host=host,port=port,filename=filename)
124
+ self.__impl(host=host,port=port)
129
125
  elif len(cmd)==3 and cmd[2]=='--cli':
130
126
  try:
131
127
  RAW_URI=cmd[1]
@@ -165,37 +161,19 @@ class web:
165
161
  try:
166
162
  os.remove(clipidpath)
167
163
  except:pass
168
- def __impl(self,host,port,filename):
164
+ def __impl(self,host,port):
169
165
  "运行测试服务器"
170
166
  try:
171
- # if config.app['http_server']=='wsgiref':
172
- # self.__http_wsgi(
173
- # host=host,
174
- # port=port,
175
- # filename=filename
176
- # )
177
- # elif config.app['http_server']=='kwebs':
178
- # self.__http_sever(
179
- # host=host,
180
- # port=port,
181
- # filename=filename
182
- # )
183
- # elif config.app['http_server']=='kwebs_server':
184
- # self.__http_server(
185
- # host=host,
186
- # port=port,
187
- # filename=filename
188
- # )
189
- # else:
190
- # self.__http_wsgi(
191
- # host=host,
192
- # port=port,
193
- # filename=filename
194
- # )
195
- self.__http_wsgi(
167
+
168
+ # self.__http_wsgi(
169
+ # host=host,
170
+ # port=port,
171
+ # filename=filename
172
+ # )
173
+
174
+ self.__waitress(
196
175
  host=host,
197
- port=port,
198
- filename=filename
176
+ port=port
199
177
  )
200
178
  except KeyboardInterrupt:
201
179
  pass
@@ -333,7 +311,6 @@ class web:
333
311
  # elif route['plug']: #配置模块但没有匹配插件
334
312
  # plug=route['plug']
335
313
  elif getplug:
336
- # print('getplug',getplug)
337
314
  plug=getplug
338
315
  routedefault,PATH_INFO=web.__getconfigroute(
339
316
  self,
@@ -356,7 +333,6 @@ class web:
356
333
  param.append(urllib.parse.unquote(path))
357
334
  i+=1
358
335
  else: #完全默认
359
- # print('完全默认')
360
336
  routedefault,PATH_INFO=web.__getconfigroute(self,PATH_INFO,header)
361
337
  if routedefault: #使用默认路由
362
338
  for path in PATH_INFO:
@@ -550,7 +526,6 @@ class web:
550
526
  status="500 Internal Server Error"
551
527
  errms=status
552
528
  if self.__config.app['app_debug']:
553
- # print(traceback.format_exc())
554
529
  errms=traceback.format_exc().split("\n")
555
530
  body=web.__tpl(
556
531
  title = status,
@@ -696,11 +671,14 @@ class web:
696
671
  # headers={"Content-Type":"application/json; charset=utf-8","Access-Control-Allow-Origin":"*"}
697
672
  # return arr,'500 error',headers
698
673
  def __application(self,env, start_response):
699
- # print(env)
700
674
  try:
701
675
  request_body_size = int(env.get('CONTENT_LENGTH', '0'))
702
676
  except (ValueError):
703
677
  request_body_size = 0
678
+ try:
679
+ env['CONTENT_TYPE']
680
+ except (KeyError):
681
+ env['CONTENT_TYPE'] = ''
704
682
  if 'multipart/form-data; boundary' in env['CONTENT_TYPE']:#上传文件
705
683
  files = cgi.FieldStorage(fp=env['wsgi.input'], environ=env, keep_blank_values=True)
706
684
  # open(form["file"].filename, 'wb').write(form["file"].value)
@@ -715,39 +693,39 @@ class web:
715
693
  env['RAW_URI']=env['PATH_INFO']
716
694
  if env.get('QUERY_STRING'):
717
695
  env['RAW_URI']=str(env['PATH_INFO'])+"?"+str(env.get('QUERY_STRING'))
718
- try:
719
- env['REMOTE_ADDR']
720
- except:
721
- env['REMOTE_ADDR']=''
722
- try:
723
- env['wsgi.url_scheme']
724
- except:
725
- env['wsgi.url_scheme']=''
726
- try:
727
- env['HTTP_X_REAL_IP']
728
- except:
729
- env['HTTP_X_REAL_IP']=''
730
- try:
731
- env['HTTP_COOKIE']
732
- except:
733
- env['HTTP_COOKIE']=''
734
- try:
735
- env['HTTP_USER_AGENT']
736
- except:
737
- env['HTTP_USER_AGENT']=''
696
+ # try:
697
+ # env['REMOTE_ADDR']
698
+ # except:
699
+ # env['REMOTE_ADDR']=''
700
+ # try:
701
+ # env['wsgi.url_scheme']
702
+ # except:
703
+ # env['wsgi.url_scheme']=''
704
+ # try:
705
+ # env['HTTP_X_REAL_IP']
706
+ # except:
707
+ # env['HTTP_X_REAL_IP']=''
708
+ # try:
709
+ # env['HTTP_COOKIE']
710
+ # except:
711
+ # env['HTTP_COOKIE']=''
712
+ # try:
713
+ # env['HTTP_USER_AGENT']
714
+ # except:
715
+ # env['HTTP_USER_AGENT']=''
738
716
  reqheader={
739
- 'REQUEST_METHOD':env['REQUEST_METHOD'],
740
- 'url_scheme':env['wsgi.url_scheme'],
741
- 'RAW_URI':env['RAW_URI'],
742
- 'PATH_INFO':env['PATH_INFO'],
743
- 'QUERY_STRING':env['QUERY_STRING'],
744
- 'SERVER_PROTOCOL':env['SERVER_PROTOCOL'],
745
- 'HTTP_HOST':env['HTTP_HOST'],
746
- 'HTTP_COOKIE':env['HTTP_COOKIE'],
747
- 'REMOTE_ADDR':env['REMOTE_ADDR'],
748
- 'HTTP_USER_AGENT':env['HTTP_USER_AGENT'],
749
- 'BODY_DATA':env['BODY_DATA'],
750
- 'HTTP_X_REAL_IP':env['HTTP_X_REAL_IP'],
717
+ 'REQUEST_METHOD':env.get('REQUEST_METHOD'),
718
+ 'url_scheme':env.get('wsgi.url_scheme'),
719
+ 'RAW_URI':env.get('RAW_URI'),
720
+ 'PATH_INFO':env.get('PATH_INFO'),
721
+ 'QUERY_STRING':env.get('QUERY_STRING'),
722
+ 'SERVER_PROTOCOL':env.get('SERVER_PROTOCOL'),
723
+ 'HTTP_HOST':env.get('HTTP_HOST'),
724
+ 'HTTP_COOKIE':env.get('HTTP_COOKIE'),
725
+ 'REMOTE_ADDR':env.get('REMOTE_ADDR'),
726
+ 'HTTP_USER_AGENT':env.get('HTTP_USER_AGENT'),
727
+ 'BODY_DATA':env.get('BODY_DATA'),
728
+ 'HTTP_X_REAL_IP':env.get('HTTP_X_REAL_IP'),
751
729
  'files':files
752
730
  }
753
731
  p=(config.app['staticpath']+reqheader['RAW_URI'].replace(' ',''))
@@ -791,9 +769,19 @@ class web:
791
769
  body=bytes(body, encoding='utf-8')
792
770
  start_response(status,resheader)
793
771
  return [body]
794
-
772
+ def __waitress(self,host,port):
773
+ if host=='0.0.0.0':
774
+ print("\033[32m* (CTRL+单击打开)http://127.0.0.1:"+str(port)+"(按CTRL+C退出)")
775
+ else:
776
+ print("\033[32m* 运行在http://"+host+":"+str(port)+"(按CTRL+C退出)")
777
+ if self.__config.app['app_debug']:
778
+ print('\033[37m* 调试器:开启')
779
+ else:
780
+ print('\033[37m* 调试器:已关闭')
781
+ from waitress import serve
782
+ serve(self.__application, host=host, port=port)
795
783
  def __http_wsgi(self,host,port,filename):
796
- "http——wsgi测试服务"
784
+ "http——wsgi测试服务 windows建议使用Waitress‌"
797
785
  from wsgiref.simple_server import make_server
798
786
  print("* \033[1;31;40m! 警告:\033[0m这是一个wsgiref开发服务器。不要在生产环境中部署使用它")
799
787
  # print('* 生产环境中建议使用gunicorn,gunicorn运行命令如:gunicorn -b '+host+':'+str(port)+' '+str(filename)+':app')
@@ -834,58 +834,6 @@ class create:
834
834
  import pip
835
835
  if not os.path.exists(self.project+self.appname):
836
836
  raise Exception('项目不存在')
837
- # if config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr=='kwebsp':
838
- # r=requests.get(config.domain['kcwebsfile']+"/kunapi/kwebsp.zip")
839
- # f = open("./"+self.project+"k.zip", "wb")
840
- # for chunk in r.iter_content(chunk_size=512):
841
- # if chunk:
842
- # f.write(chunk)
843
- # f.close()
844
- # kcwszip.unzip_file("./"+self.project+"kwebsp.zip","./"+self.project+self.appname)
845
- # os.remove("./"+self.project+"kwebsp.zip")
846
- # elif config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr=='kwebs':
847
- # r=requests.get(config.domain['kcwebsfile']+"/kunapi/kwebs.zip")
848
- # f = open("./"+self.project+"kwebs.zip", "wb")
849
- # for chunk in r.iter_content(chunk_size=512):
850
- # if chunk:
851
- # f.write(chunk)
852
- # f.close()
853
- # kcwszip.unzip_file("./"+self.project+"kwebs.zip","./"+self.project+self.appname)
854
- # os.remove("./"+self.project+"kwebs.zip")
855
- # elif config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr=='kunapi':
856
- # r=requests.get(config.domain['kcwebsfile']+"/kapi/kapi.zip")
857
- # f = open("./"+self.project+"kapi.zip", "wb")
858
- # for chunk in r.iter_content(chunk_size=512):
859
- # if chunk:
860
- # f.write(chunk)
861
- # f.close()
862
- # kcwszip.unzip_file("./"+self.project+"kapi.zip","./"+self.project+self.appname)
863
- # os.remove("./"+self.project+"kapi.zip")
864
- # else:
865
- # raise Exception('包名错误')
866
- # if not os.path.isfile("./"+self.project+"server.py"):
867
- # # if "Windows" in platform.platform():
868
- # # pythonname="python"
869
- # # else:
870
- # # pythonname="python3.8"
871
- # servertext=('#项目运行文件,请务修改\n'+
872
- # 'import kunapi,sys,'+self.appname+'\n'+
873
- # 'app=kunapi.web(__name__,'+self.appname+')\n'+
874
- # 'if __name__ == "__main__":\n'+
875
- # ' try:\n'+
876
- # ' route=sys.argv[1]\n'+
877
- # ' if "eventlog"==route:\n'+
878
- # ' raise Exception("")\n'+
879
- # ' except:\n'+
880
- # ' #host监听ip port端口 name python解释器名字 (windows一般是python linux一般是python3) \n'+
881
- # ' app.run(host="0.0.0.0",port="39001",name="python3.8")\n'+
882
- # ' else:\n'+
883
- # ' app.cli(route)\n'
884
- # )
885
- # f=open("./"+self.project+"server.py","w+",encoding='utf-8')
886
- # f.write(servertext)
887
- # f.close()
888
- # return True,"应用创建成功"
889
837
  else:
890
838
  if not os.path.isfile(self.project+self.appname+"/__init__.py") or not os.path.exists(self.project+self.appname+"/common"):
891
839
  return False,self.appname+"不是kunapi应用"
@@ -1010,22 +958,6 @@ class create:
1010
958
  f.close()
1011
959
  else:
1012
960
  return False,self.modular+"模块下载失败"
1013
- if not os.path.isfile("./server.py"):
1014
- if "Windows" in platform.platform():
1015
- pythonname="python"
1016
- else:
1017
- pythonname="python3"
1018
- # sys.argv[0]=re.sub('.py','',sys.argv[0])
1019
- servertext=('# -*- coding: utf-8 -*-\n#gunicorn -b 0.0.0.0:39010 '+self.appname+':app\n'+
1020
- 'from kunapi import web\n'+
1021
- 'import '+self.appname+' as application\n'+
1022
- 'app=web(__name__,application)\n'+
1023
- 'if __name__ == "__main__":\n'+
1024
- ' #host监听ip port端口 name python解释器名字 (windows一般是python linux一般是python3)\n'+
1025
- ' app.run(host="0.0.0.0",port="39001",name="'+pythonname+'")')
1026
- f=open("./"+self.project+"server.py","w+",encoding='utf-8')
1027
- f.write(servertext)
1028
- f.close()
1029
961
  return True,"安装成功"
1030
962
  else:
1031
963
 
@@ -164,34 +164,7 @@ def cllfunction():
164
164
  print("\033[32m"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+" --modular api --uninstall 卸载app/api模块")
165
165
  print("\033[32m"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+" --modular api --plug plug1 --uninstall 卸载app/api/plug1插件\n")
166
166
  else:
167
- # if cmd_par['cli']:#通过命令行执行控制器的方法
168
- # try:
169
- # obj=importlib.import_module(cmd_par['appname']+'.common')
170
- # if obj.config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr!=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1:
171
- # print("该项目只能使用"+obj.config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr+"开头的命令!")
172
- # exit()
173
- # except Exception as e:
174
- # print('项目不合法',traceback.format_exc())
175
- # exit()
176
- # config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1
177
- # from kunapi import web
178
- # try:
179
- # import app as application
180
- # except Exception as e:
181
- # if "No module named 'app'" in str(e):
182
- # print("请在"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+"项目下运行")
183
- # else:
184
- # print(traceback.format_exc())
185
- # exit()
186
- # else:
187
- # app=web(__name__,application)
188
- # try:
189
- # RAW_URI=sys.argv[1]
190
- # except:pass
191
- # else:
192
- # if RAW_URI=='--cli':
193
- # RAW_URI=''
194
- # app.cli(RAW_URI)
167
+
195
168
 
196
169
  if cmd_par['update']:#更新kunapi包:
197
170
  # print(fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1)
@@ -253,7 +226,6 @@ def cllfunction():
253
226
  if bs==fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1:
254
227
  break
255
228
  elif cmd_par['server']:#启动web服务
256
-
257
229
  try:
258
230
  obj=importlib.import_module(cmd_par['appname']+'.common')
259
231
  if obj.config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr!=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1:
@@ -264,25 +236,34 @@ def cllfunction():
264
236
  exit()
265
237
  config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1
266
238
  types=sys.argv[len(sys.argv)-1]
267
- if get_sysinfo()['uname'][0]=='Linux':
239
+ if os.name == 'nt':
240
+ from kunapi import web
241
+ try:
242
+ import app as application
243
+ except Exception as e:
244
+ if "No module named 'app'" in str(e):
245
+ print("请在"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+"项目下运行")
246
+ else:
247
+ print(traceback.format_exc())
248
+ exit()
249
+ else:
250
+ app=web(__name__,application)
251
+ if __name__ == 'kunapi.kunapi':
252
+ tar=len(sys.argv)
253
+ kill_route_cli('pid/'+str(sys.argv[tar-1])+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+'_server_pid')
254
+ if types=='-stop':
255
+ pass
256
+ else:
257
+ save_route_cli_pid('pid/'+str(sys.argv[tar-1])+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+'_server_pid')
258
+ app.run(host=cmd_par['host'],port=int(cmd_par['port']))
259
+ else:
268
260
  pythonpath=site.getsitepackages()[0].replace('\\','/')
269
261
  t=pythonpath.split('/')
270
262
  tt='/'+t[-3]+'/'+t[-2]+'/'+t[-1]
271
263
  pythonpath=pythonpath.replace(tt,'')
272
264
  if not os.path.exists('/usr/bin/'+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1) and os.path.isfile(pythonpath+'/bin/'+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1):
273
265
  os.system("ln -s "+pythonpath+"/bin/"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+" /usr/bin/"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1)
274
- # if types=='-stop' or types=='-start':
275
- # pass
276
- # else:
277
- # print("启动参数错误,支持 -start和-stop")
278
- # exit()
279
- # try:
280
- # f=open("pid",'r')
281
- # pid=f.read()
282
- # f.close()
283
- # if pid:
284
- # os.system("kill "+pid)
285
- # except:pass
266
+
286
267
  if __name__ == 'kunapi.kunapi':
287
268
  kill_route_cli('pid/'+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+'_server_pid')
288
269
  try:
@@ -300,26 +281,7 @@ def cllfunction():
300
281
  sys.argv=[sys.argv[0], '-w', str(cmd_par['processcount']), '-b', cmd_par['host']+':'+str(cmd_par['port']),'-t',cmd_par['timeout'], 'server:'+cmd_par['appname']]
301
282
  sys.exit(run())
302
283
  exit()
303
- else:
304
- from kunapi import web
305
- try:
306
- import app as application
307
- except Exception as e:
308
- if "No module named 'app'" in str(e):
309
- print("请在"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+"项目下运行")
310
- else:
311
- print(traceback.format_exc())
312
- exit()
313
- else:
314
- app=web(__name__,application)
315
- if __name__ == 'kunapi.kunapi':
316
- tar=len(sys.argv)
317
- kill_route_cli('pid/'+str(sys.argv[tar-1])+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+'_server_pid')
318
- if types=='-stop':
319
- pass
320
- else:
321
- save_route_cli_pid('pid/'+str(sys.argv[tar-1])+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+'_server_pid')
322
- app.run(host=cmd_par['host'],port=int(cmd_par['port']))
284
+
323
285
  elif cmd_par['install'] or cmd_par['pack'] or cmd_par['upload'] or cmd_par['uninstall']:
324
286
  if cmd_par['install']:#插入 应用、模块、插件
325
287
  if cmd_par['appname'] and cmd_par['modular']:
@@ -335,13 +297,13 @@ def cllfunction():
335
297
  remppath=os.path.split(os.path.realpath(__file__))[0]
336
298
  if not os.path.exists(cmd_par['project']+'/'+cmd_par['appname']) and not os.path.exists(cmd_par['appname']):
337
299
  shutil.copytree(remppath+'/tempfile/kunapi',cmd_par['project'])
338
- if get_sysinfo()['uname'][0]=='Linux':
300
+ if os.name == 'nt':
339
301
  try:
340
- os.remove(cmd_par['project']+"/server.bat")
302
+ os.remove(cmd_par['project']+"/server.sh")
341
303
  except:pass
342
- elif get_sysinfo()['uname'][0]=='Windows':
304
+ else:
343
305
  try:
344
- os.remove(cmd_par['project']+"/server.sh")
306
+ os.remove(cmd_par['project']+"/server.bat")
345
307
  except:pass
346
308
  print('kunapi项目创建成功')
347
309
  exit()
@@ -421,7 +383,35 @@ def cllfunction():
421
383
  else:
422
384
  print("\033[1;31;40m卸载时 必须指定应该app和modular,参考命令: "+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+" --app app --modular api")
423
385
  exit()
424
- else:
386
+ elif cmd_par['cli']:#通过命令行执行控制器的方法
387
+ try:
388
+ obj=importlib.import_module(cmd_par['appname']+'.common')
389
+ if obj.config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr!=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1:
390
+ print("该项目只能使用"+obj.config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr+"开头的命令!")
391
+ exit()
392
+ except Exception as e:
393
+ print('项目不合法',traceback.format_exc())
394
+ exit()
395
+ config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1
396
+ from kunapi import web
397
+ try:
398
+ import app as application
399
+ except Exception as e:
400
+ if "No module named 'app'" in str(e):
401
+ print("请在"+fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1+"项目下运行")
402
+ else:
403
+ print(traceback.format_exc())
404
+ exit()
405
+ else:
406
+ app=web(__name__,application)
407
+ try:
408
+ RAW_URI=sys.argv[1]
409
+ except:pass
410
+ else:
411
+ if RAW_URI=='--cli':
412
+ RAW_URI=''
413
+ app.cli(RAW_URI)
414
+ else:#通过命令行执行控制器的方法
425
415
  try:
426
416
  obj=importlib.import_module(cmd_par['appname']+'.common')
427
417
  if obj.config.fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr!=fdgrsgrsegsrsgrsbsdbftbrsbfdrtrtbdfsrsgr1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: kunapi
3
- Version: 1.3
3
+ Version: 1.5
4
4
  Summary: kunapi
5
5
  Home-page: https://docs.kwebapp.cn/index/index/2
6
6
  Author: 百里-坤坤
@@ -9,5 +9,5 @@ Maintainer: 坤坤
9
9
  Maintainer-email: fengkun01@qq.com
10
10
  License: MIT License
11
11
  Description: kunapi
12
- Keywords: kunapi1.3
12
+ Keywords: kunapi1.5
13
13
  Platform: UNKNOWN
@@ -14,30 +14,6 @@ kunapi/common/autoload.py
14
14
  kunapi/common/globals.py
15
15
  kunapi/common/request.py
16
16
  kunapi/config/__init__.py
17
- kunapi/tempfile/__init__.py
18
- kunapi/tempfile/kunapi/server.py
19
- kunapi/tempfile/kunapi/app/__init__.py
20
- kunapi/tempfile/kunapi/app/common/__init__.py
21
- kunapi/tempfile/kunapi/app/common/autoload.py
22
- kunapi/tempfile/kunapi/app/common/model.py
23
- kunapi/tempfile/kunapi/app/config/__init__.py
24
- kunapi/tempfile/kunapi/app/config/app.py
25
- kunapi/tempfile/kunapi/app/index/__init__.py
26
- kunapi/tempfile/kunapi/app/index/common/__init__.py
27
- kunapi/tempfile/kunapi/app/index/common/autoload.py
28
- kunapi/tempfile/kunapi/app/index/controller/__init__.py
29
- kunapi/tempfile/kunapi/app/index/controller/index/__init__.py
30
- kunapi/tempfile/kunapi/app/index/controller/index/index.py
31
- kunapi/tempfile/kunapi/app/index/controller/index/common/__init__.py
32
- kunapi/tempfile/kunapi/app/index/controller/index/common/autoload.py
33
- kunapi/tempfile/kunapi/app/index/controller/index/common/model.py
34
- kunapi/common/__init__.py
35
- kunapi/common/autoload.py
36
- kunapi/common/globals.py
37
- kunapi/common/request.py
38
- kunapi/config/__init__.py
39
- kunapi/tempfile/__init__.py
40
- kunapi/tempfile/kunapi/server.py
41
17
  kunapi/tempfile/kunapi/app/__init__.py
42
18
  kunapi/tempfile/kunapi/app/common/__init__.py
43
19
  kunapi/tempfile/kunapi/app/common/autoload.py
@@ -1,4 +1,5 @@
1
1
  gunicorn==20.0.4
2
+ waitress==3.0.0
2
3
  watchdog==4.0.0
3
4
  filetype==1.2.0
4
5
  psutil==5.8.0
@@ -31,7 +31,7 @@ def start():
31
31
  maintainer_email = kcwsinfo["maintainer_email"],
32
32
  url=kcwsinfo['url'],
33
33
  packages = b,
34
- install_requires = ['gunicorn==20.0.4','watchdog==4.0.0','filetype==1.2.0','psutil==5.8.0','requests==2.32.4'], #第三方包
34
+ install_requires = ['gunicorn==20.0.4','waitress==3.0.0','watchdog==4.0.0','filetype==1.2.0','psutil==5.8.0','requests==2.32.4'], #第三方包
35
35
  package_data = {
36
36
  '': ['*.html', '*.js','*.css','*.jpg','*.png','*.gif'],
37
37
  },
@@ -1,3 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # #导入模块
3
- from . import index
@@ -1,13 +0,0 @@
1
- #项目运行文件,请务修改
2
- import kunapi,sys,app
3
- app=kunapi.web(__name__,app)
4
- if __name__ == "__main__":
5
- try:
6
- route=sys.argv[1]
7
- if "eventlog"==route:
8
- raise Exception("")
9
- except:
10
- #host监听ip port端口 name python解释器名字 (windows一般是python linux一般是python3)
11
- app.run(host="0.0.0.0",port="3000",name="python3.8")
12
- else:
13
- app.cli(route)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes