gomyck-tools 1.0.3__py3-none-any.whl → 1.0.4__py3-none-any.whl

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.
@@ -1,8 +1,6 @@
1
1
  from bottle import ServerAdapter
2
2
  from socketserver import ThreadingMixIn
3
3
  from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, make_server
4
- from geventwebsocket.handler import WebSocketHandler
5
- from ctools import sys_log
6
4
 
7
5
  """
8
6
  app = init_app('/doc_download')
@@ -42,15 +40,6 @@ class ThreadedWSGIServer(ThreadingMixIn, WSGIServer): pass
42
40
  class CustomWSGIHandler(WSGIRequestHandler):
43
41
  def log_request(*args, **kw): pass
44
42
 
45
- class CustomWebSocketHandler(WebSocketHandler):
46
- def log_request(self):
47
- if '101' not in str(self.status):
48
- log_msg = self.format_request()
49
- for nk in sys_log.neglect_keywords:
50
- if nk in log_msg:
51
- return
52
- self.logger.info(log_msg)
53
-
54
43
  class WSGIRefServer(ServerAdapter):
55
44
 
56
45
  def __init__(self, host='0.0.0.0', port=8010):
@@ -65,18 +54,3 @@ class WSGIRefServer(ServerAdapter):
65
54
 
66
55
  def stop(self):
67
56
  self.server.shutdown()
68
-
69
-
70
- class WebSocketServer(ServerAdapter):
71
-
72
- def __init__(self, host='0.0.0.0', port=8011):
73
- super().__init__(host, port)
74
- self.server = None
75
-
76
- def run(self, handler):
77
- from gevent import pywsgi
78
- self.server = pywsgi.WSGIServer((self.host, self.port), handler, handler_class=CustomWebSocketHandler)
79
- self.server.serve_forever()
80
-
81
- def stop(self):
82
- self.server.stop()
@@ -0,0 +1,57 @@
1
+ from bottle import ServerAdapter
2
+ from geventwebsocket.handler import WebSocketHandler
3
+ from ctools import sys_log
4
+
5
+ """
6
+ app = init_app('/websocket_demo')
7
+
8
+ @app.route('/script_debug', apply=[websocket])
9
+ @rule('DOC:DOWNLOAD')
10
+ def script_debug(ws: WebSocket):
11
+ """
12
+
13
+ """
14
+ module_names = list(globals().keys())
15
+ def get_modules():
16
+ mods = []
17
+ for modname in module_names:
18
+ if modname == 'base' or modname == 'online' or modname.startswith('__') or modname == 'importlib': continue
19
+ module = globals()[modname]
20
+ mods.append(module)
21
+ return mods
22
+
23
+ def get_ws_modules():
24
+ from . import websocket
25
+ return [websocket]
26
+ """
27
+
28
+ """
29
+ http_app = Bottle()
30
+ for module in controller.get_modules():
31
+ log.debug('正在挂载http路由: {}'.format(module.app.context_path))
32
+ http_app.mount(module.app.context_path, module.app)
33
+ http_server = bottle_server.WSGIRefServer(port=application.Server.port)
34
+ http_app.run(server=http_server, quiet=True)
35
+ """
36
+ class CustomWebSocketHandler(WebSocketHandler):
37
+ def log_request(self):
38
+ if '101' not in str(self.status):
39
+ log_msg = self.format_request()
40
+ for nk in sys_log.neglect_keywords:
41
+ if nk in log_msg:
42
+ return
43
+ self.logger.info(log_msg)
44
+
45
+ class WebSocketServer(ServerAdapter):
46
+
47
+ def __init__(self, host='0.0.0.0', port=8011):
48
+ super().__init__(host, port)
49
+ self.server = None
50
+
51
+ def run(self, handler):
52
+ from gevent import pywsgi
53
+ self.server = pywsgi.WSGIServer((self.host, self.port), handler, handler_class=CustomWebSocketHandler)
54
+ self.server.serve_forever()
55
+
56
+ def stop(self):
57
+ self.server.stop()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gomyck-tools
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: A ctools for python development by hao474798383
5
5
  Home-page: https://blog.gomyck.com
6
6
  Author: gomyck
@@ -4,7 +4,8 @@ ctools/api_result.py,sha256=NiM-R9K42G3m16B27sG_mqKrlexZzC5-LKoY8D5tO4s,1239
4
4
  ctools/application.py,sha256=WviU7p9GOqducbGW3XGkP7jCNKmraCh6JGSYBC33CQk,16008
5
5
  ctools/b64.py,sha256=_BdhX3p3-MaSSlU2wivN5qPxQfacR3VRBr1WC456tU0,194
6
6
  ctools/bashPath.py,sha256=BCN_EhYzqvwsxYso81omMNd3SbEociwSOyb9kLvu8V4,337
7
- ctools/bottle_server.py,sha256=9gmw1og_8ZaOfmF8X9pwDlRxxeo648QmFvLl0shV0Dk,2303
7
+ ctools/bottle_webserver.py,sha256=ssZSepcihbukOl-BUyPLYdj4jsQRBoD6Dq4rqjss5YE,1572
8
+ ctools/bottle_websocket.py,sha256=aO5s1zlPVxjUj86529UkEXywmuaDK5qFvorsW5RIBEY,1583
8
9
  ctools/browser_element_tools.py,sha256=tWNxUJ9m-hNTYtS0NRvmH9r5I-Qw55uKekwDYgt49bc,9951
9
10
  ctools/call.py,sha256=BCr8wzt5qd70okv8IZn-9-EpjywleZgvA3u1vfZ_Kt8,1581
10
11
  ctools/cjson.py,sha256=M2XrXnFXTJyKsXP2JRos2Bse4b6WXjr6TrA6y-EF_Ig,1245
@@ -50,7 +51,7 @@ ctools/wordFill.py,sha256=dB1OLt6GLmWdkDV8H20VWbJmY4ggNNI8iHD1ocae2iM,875
50
51
  ctools/word_fill.py,sha256=aIkzjAF2soSW6w2dO2CRZlveDcuIdr6v9DtyyyB8uxM,18216
51
52
  ctools/word_fill_entity.py,sha256=eX3G0Gy16hfGpavQSEkCIoKDdTnNgRRJrFvKliETZK8,985
52
53
  ctools/work_path.py,sha256=i4MTUobqNW2WMrT3mwEC_XYQ0_IhFmKoNpTX2W6A8Tc,1680
53
- gomyck_tools-1.0.3.dist-info/METADATA,sha256=PQAV6lBWaVLR5zlq6_Zr0KbmCLDRaib8WVn3M4jngIo,712
54
- gomyck_tools-1.0.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
55
- gomyck_tools-1.0.3.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
56
- gomyck_tools-1.0.3.dist-info/RECORD,,
54
+ gomyck_tools-1.0.4.dist-info/METADATA,sha256=iS_5GtFgNjro54IcaZQVyLKycAqwN_ghaZAuy2buDYU,712
55
+ gomyck_tools-1.0.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
56
+ gomyck_tools-1.0.4.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
57
+ gomyck_tools-1.0.4.dist-info/RECORD,,