cloudoll 2.2.32__tar.gz → 2.2.34__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.
- {cloudoll-2.2.32 → cloudoll-2.2.34}/PKG-INFO +2 -1
- cloudoll-2.2.34/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/cli.py +2 -2
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/web/__init__.py +67 -11
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/web/settings.py +8 -4
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll.egg-info/PKG-INFO +2 -1
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll.egg-info/requires.txt +1 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/setup.py +2 -1
- cloudoll-2.2.32/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.32 → cloudoll-2.2.34}/LICENSE +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/README.md +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/__init__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/field.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/model.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/utils/m2d.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/utils/snowflake.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/utils/watch.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.32 → cloudoll-2.2.34}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cloudoll
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.34
|
|
4
4
|
Summary: 辅助快速创建可分布的微服务。
|
|
5
5
|
Home-page: https://gitee.com/chuchur/cloudoll-py
|
|
6
6
|
Author: chuchur
|
|
@@ -28,6 +28,7 @@ Requires-Dist: pyjwt
|
|
|
28
28
|
Requires-Dist: aiohttp_session[secure]
|
|
29
29
|
Requires-Dist: PyYAML
|
|
30
30
|
Requires-Dist: click
|
|
31
|
+
Requires-Dist: envyaml
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
# cloudoll 云端玩具
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.34"
|
|
@@ -115,8 +115,8 @@ def start(environment, host, port, mode, path, entry) -> None:
|
|
|
115
115
|
except KeyboardInterrupt:
|
|
116
116
|
sys.exit(0)
|
|
117
117
|
except Exception as e:
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
print_error(e)
|
|
119
|
+
print_error(traceback.format_exc())
|
|
120
120
|
sys.exit(0)
|
|
121
121
|
|
|
122
122
|
|
|
@@ -13,7 +13,7 @@ import inspect
|
|
|
13
13
|
import json
|
|
14
14
|
from errno import EADDRINUSE
|
|
15
15
|
from urllib import parse
|
|
16
|
-
from aiohttp import web
|
|
16
|
+
from aiohttp import web, hdrs
|
|
17
17
|
from aiohttp.web import Response
|
|
18
18
|
from aiohttp.web_ws import WebSocketResponse, StreamResponse, WSMsgType
|
|
19
19
|
from aiohttp.web_response import LooseHeaders
|
|
@@ -38,7 +38,7 @@ from ..orm import create_engine, parse_coon
|
|
|
38
38
|
import uuid
|
|
39
39
|
|
|
40
40
|
# from ..orm.mysql import Mysql
|
|
41
|
-
from typing import Optional, Iterable
|
|
41
|
+
from typing import Optional, Iterable, Callable, Awaitable
|
|
42
42
|
|
|
43
43
|
__ALL__ = (
|
|
44
44
|
"app",
|
|
@@ -46,21 +46,22 @@ __ALL__ = (
|
|
|
46
46
|
"Response",
|
|
47
47
|
"WebStream",
|
|
48
48
|
"WSMsgType",
|
|
49
|
-
"
|
|
49
|
+
"View",
|
|
50
|
+
"routes" "get",
|
|
50
51
|
"put",
|
|
51
52
|
"delete",
|
|
53
|
+
"post",
|
|
52
54
|
"render_json",
|
|
53
55
|
"render_error",
|
|
54
|
-
"middleware",
|
|
55
56
|
"render_view",
|
|
57
|
+
"middleware",
|
|
56
58
|
"redirect",
|
|
57
59
|
"jwt",
|
|
58
60
|
)
|
|
59
61
|
|
|
60
62
|
|
|
61
63
|
class RequestHandler(object):
|
|
62
|
-
def __init__(self,
|
|
63
|
-
self.cls = cls
|
|
64
|
+
def __init__(self, fn):
|
|
64
65
|
self.fn = fn
|
|
65
66
|
|
|
66
67
|
async def __call__(self, request):
|
|
@@ -182,7 +183,7 @@ class Application(object):
|
|
|
182
183
|
return
|
|
183
184
|
entry = importlib.import_module(entry_model, ".")
|
|
184
185
|
|
|
185
|
-
life_cycle = ["on_startup", "on_shutdown", "on_cleanup", "
|
|
186
|
+
life_cycle = ["on_startup", "on_shutdown", "on_cleanup", "on_task"]
|
|
186
187
|
for cycle in life_cycle:
|
|
187
188
|
if hasattr(entry, cycle):
|
|
188
189
|
cy = getattr(self, cycle)
|
|
@@ -391,7 +392,7 @@ class Application(object):
|
|
|
391
392
|
|
|
392
393
|
def add_router(self, path, method, name):
|
|
393
394
|
def inner(handler):
|
|
394
|
-
handler = RequestHandler(
|
|
395
|
+
handler = RequestHandler(handler)
|
|
395
396
|
self.app.router.add_route(method, path, handler, name=name)
|
|
396
397
|
return handler
|
|
397
398
|
|
|
@@ -435,10 +436,66 @@ class Application(object):
|
|
|
435
436
|
return self.app.on_cleanup
|
|
436
437
|
|
|
437
438
|
@property
|
|
438
|
-
def
|
|
439
|
+
def on_task(self):
|
|
439
440
|
return self.app.cleanup_ctx
|
|
440
441
|
|
|
441
442
|
|
|
443
|
+
class View(web.View):
|
|
444
|
+
async def _iter(self) -> StreamResponse:
|
|
445
|
+
request = self.request
|
|
446
|
+
if request.method not in hdrs.METH_ALL:
|
|
447
|
+
self._raise_allowed_methods()
|
|
448
|
+
method: Optional[Callable[[], Awaitable[StreamResponse]]]
|
|
449
|
+
method = getattr(self, request.method.lower(), None)
|
|
450
|
+
if method is None:
|
|
451
|
+
self._raise_allowed_methods()
|
|
452
|
+
# result = await method()
|
|
453
|
+
# assert isinstance(ret, StreamResponse)
|
|
454
|
+
# return ret
|
|
455
|
+
content_type = request.content_type
|
|
456
|
+
# 获取函数参数的名称和默认值
|
|
457
|
+
props = inspect.getfullargspec(method)
|
|
458
|
+
if len(props.args) == 3 and content_type == "multipart/form-data":
|
|
459
|
+
await set_session_route(request)
|
|
460
|
+
multipart = await request.multipart()
|
|
461
|
+
field = await multipart.next()
|
|
462
|
+
result = await method(request, field)
|
|
463
|
+
elif len(props.args) == 2:
|
|
464
|
+
await set_session_route(request)
|
|
465
|
+
if content_type == "multipart/form-data":
|
|
466
|
+
data = await request.post()
|
|
467
|
+
elif content_type == "application/json":
|
|
468
|
+
data = await request.json()
|
|
469
|
+
else:
|
|
470
|
+
data = await request.post()
|
|
471
|
+
query_string = request.query_string
|
|
472
|
+
body = {}
|
|
473
|
+
for k in data:
|
|
474
|
+
body[k] = data[k]
|
|
475
|
+
qs = {}
|
|
476
|
+
if query_string:
|
|
477
|
+
for k, v in parse.parse_qs(query_string, True).items():
|
|
478
|
+
qs[k] = v[0]
|
|
479
|
+
request.qs = Object(qs)
|
|
480
|
+
request.body = Object(body)
|
|
481
|
+
result = await method(request)
|
|
482
|
+
else:
|
|
483
|
+
result = await method()
|
|
484
|
+
try:
|
|
485
|
+
if isinstance(result, Response):
|
|
486
|
+
return result
|
|
487
|
+
if isinstance(result, StreamResponse):
|
|
488
|
+
return result
|
|
489
|
+
if isinstance(result, WebSocketResponse): # maybe catch error
|
|
490
|
+
return result
|
|
491
|
+
if "content_type" in result and "text/html" in result["content_type"]:
|
|
492
|
+
return result
|
|
493
|
+
except:
|
|
494
|
+
pass
|
|
495
|
+
|
|
496
|
+
return render_json(result)
|
|
497
|
+
|
|
498
|
+
|
|
442
499
|
app = Application()
|
|
443
500
|
|
|
444
501
|
|
|
@@ -510,8 +567,7 @@ def delete(path: str, name=None):
|
|
|
510
567
|
return app.add_router(path, "DELETE", name)
|
|
511
568
|
|
|
512
569
|
|
|
513
|
-
def
|
|
514
|
-
# return app._actions(path, 'GET')
|
|
570
|
+
def routes(path: str):
|
|
515
571
|
return app.route_table.view(path)
|
|
516
572
|
|
|
517
573
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import yaml
|
|
2
2
|
import os
|
|
3
3
|
from ..logging import print_error, print_info
|
|
4
4
|
from envyaml import EnvYAML
|
|
@@ -12,7 +12,11 @@ def get_config(env):
|
|
|
12
12
|
if not os.path.exists(conf_path):
|
|
13
13
|
print_error(f"Configuration file does not exist: {conf_path}")
|
|
14
14
|
return {}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
with open(conf_path, "r", encoding="utf-8") as f:
|
|
16
|
+
config = yaml.safe_load(f)
|
|
17
|
+
try:
|
|
18
|
+
config_ori = EnvYAML(conf_path, strict=False)
|
|
19
|
+
config = dict(config_ori)
|
|
20
|
+
except BaseException as e:
|
|
21
|
+
print_error(e)
|
|
18
22
|
return config or {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cloudoll
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.34
|
|
4
4
|
Summary: 辅助快速创建可分布的微服务。
|
|
5
5
|
Home-page: https://gitee.com/chuchur/cloudoll-py
|
|
6
6
|
Author: chuchur
|
|
@@ -28,6 +28,7 @@ Requires-Dist: pyjwt
|
|
|
28
28
|
Requires-Dist: aiohttp_session[secure]
|
|
29
29
|
Requires-Dist: PyYAML
|
|
30
30
|
Requires-Dist: click
|
|
31
|
+
Requires-Dist: envyaml
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
# cloudoll 云端玩具
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.32"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|