gomyck-tools 1.0.2__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.
- ctools/{bottle_server.py → bottle_webserver.py} +0 -26
- ctools/bottle_websocket.py +57 -0
- ctools/cjson.py +1 -1
- {gomyck_tools-1.0.2.dist-info → gomyck_tools-1.0.4.dist-info}/METADATA +2 -2
- {gomyck_tools-1.0.2.dist-info → gomyck_tools-1.0.4.dist-info}/RECORD +7 -6
- {gomyck_tools-1.0.2.dist-info → gomyck_tools-1.0.4.dist-info}/WHEEL +0 -0
- {gomyck_tools-1.0.2.dist-info → gomyck_tools-1.0.4.dist-info}/top_level.txt +0 -0
@@ -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()
|
ctools/cjson.py
CHANGED
@@ -4,7 +4,7 @@ import jsonpickle
|
|
4
4
|
str_value_keys = []
|
5
5
|
jsonpickle.set_preferred_backend('json')
|
6
6
|
jsonpickle.set_encoder_options('json', ensure_ascii=False)
|
7
|
-
jsonpickle.set_decoder_options('json'
|
7
|
+
jsonpickle.set_decoder_options('json')
|
8
8
|
|
9
9
|
def dumps(obj) -> str:
|
10
10
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: gomyck-tools
|
3
|
-
Version: 1.0.
|
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
|
@@ -15,8 +15,8 @@ Requires-Dist: SQLAlchemy >=2.0.32
|
|
15
15
|
Requires-Dist: chardet >=5.2.0
|
16
16
|
Requires-Dist: psycopg2-binary >=2.9.9
|
17
17
|
Requires-Dist: croniter >=3.0.3
|
18
|
-
Requires-Dist: pyautogui >=0.9.54
|
19
18
|
Requires-Dist: gmssl >=3.2.2
|
20
19
|
Requires-Dist: psutil >=6.0.0
|
20
|
+
Requires-Dist: jsonpath-ng >=1.6.1
|
21
21
|
|
22
22
|
this package is for python development
|
@@ -4,10 +4,11 @@ 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/
|
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
|
-
ctools/cjson.py,sha256=
|
11
|
+
ctools/cjson.py,sha256=M2XrXnFXTJyKsXP2JRos2Bse4b6WXjr6TrA6y-EF_Ig,1245
|
11
12
|
ctools/ckafka.py,sha256=win6iV9-7FJDzcmqwQ5httN_NWjrBlWHc5b7N9E5tCQ,5187
|
12
13
|
ctools/compile_tools.py,sha256=Nybh3vnkurIKnPnubdYzigjnzFu4GaTMKPvqFdibxmE,510
|
13
14
|
ctools/console.py,sha256=1VAq_-fSGgHKYv6Qe53kHaJL0-3NpFRUZljahbJPcfk,1807
|
@@ -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.
|
54
|
-
gomyck_tools-1.0.
|
55
|
-
gomyck_tools-1.0.
|
56
|
-
gomyck_tools-1.0.
|
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,,
|
File without changes
|
File without changes
|