cloudoll 2.2.10__tar.gz → 2.2.12__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 (43) hide show
  1. {cloudoll-2.2.10 → cloudoll-2.2.12}/PKG-INFO +1 -1
  2. cloudoll-2.2.12/cloudoll/__init__.py +1 -0
  3. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/cli.py +17 -7
  4. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/mail/smtp.py +2 -2
  5. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/__init__.py +1 -1
  6. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/base.py +1 -1
  7. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/mysql.py +3 -2
  8. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/postgres.py +7 -2
  9. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/robot/dingtalk.py +8 -8
  10. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/robot/feishu.py +6 -6
  11. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/utils/watch.py +3 -1
  12. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/web/__init__.py +4 -4
  13. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll.egg-info/PKG-INFO +1 -1
  14. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll.egg-info/requires.txt +1 -1
  15. {cloudoll-2.2.10 → cloudoll-2.2.12}/setup.py +2 -1
  16. cloudoll-2.2.10/cloudoll/__init__.py +0 -1
  17. {cloudoll-2.2.10 → cloudoll-2.2.12}/LICENSE +0 -0
  18. {cloudoll-2.2.10 → cloudoll-2.2.12}/README.md +0 -0
  19. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/__main__.py +0 -0
  20. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/error/__init__.py +0 -0
  21. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/error/errors.py +0 -0
  22. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/logging/__init__.py +0 -0
  23. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/mail/__init__.py +0 -0
  24. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/err.py +0 -0
  25. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/field.py +0 -0
  26. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/model.py +0 -0
  27. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/orm/parse.py +0 -0
  28. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/robot/__init__.py +0 -0
  29. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/robot/slack.py +0 -0
  30. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/utils/__init__.py +0 -0
  31. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/utils/common.py +0 -0
  32. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/utils/m2d.py +0 -0
  33. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/utils/patch_loop.py +0 -0
  34. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/web/exception.py +0 -0
  35. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/web/html.py +0 -0
  36. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/web/http.py +0 -0
  37. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/web/jwt.py +0 -0
  38. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll/web/settings.py +0 -0
  39. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll.egg-info/SOURCES.txt +0 -0
  40. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll.egg-info/dependency_links.txt +0 -0
  41. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll.egg-info/entry_points.txt +0 -0
  42. {cloudoll-2.2.10 → cloudoll-2.2.12}/cloudoll.egg-info/top_level.txt +0 -0
  43. {cloudoll-2.2.10 → cloudoll-2.2.12}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloudoll
3
- Version: 2.2.10
3
+ Version: 2.2.12
4
4
  Summary: 辅助快速创建可分布的微服务。
5
5
  Home-page: https://gitee.com/chuchur/cloudoll-py
6
6
  Author: chuchur
@@ -0,0 +1 @@
1
+ __version__ = "2.2.12"
@@ -76,23 +76,31 @@ def gen(path, create, table, environment, database) -> None:
76
76
 
77
77
  @cli.command()
78
78
  @click.option("-env", "--environment", help="Environment, local / test / prod", default="local")
79
- @click.option("-p", "--port", help="Server's port", default=None)
80
- @click.option("-h", "--host", help="Server's host", default=None)
79
+ @click.option("-p", "--port", help="Server's port", default=9001)
80
+ @click.option("-h", "--host", help="Server's host", default='0.0.0.0')
81
+ @click.option("-m", "--mode", help="development or production mode", default='development')
81
82
  @click.option("-path", "--path",help="Unix file system path to serve on. Specifying a path will cause hostname and port arguments to be ignored.",)
82
- @click.option("-m", "--model", help="Entry point model name. delfault name app", default="app")
83
- def start(environment, host, port, path, model) -> None:
83
+ @click.option("-e", "--entry", help="Entry point model name. delfault name app", default="app")
84
+ def start(environment, host, port, mode, path, entry) -> None:
84
85
  """Start a services."""
85
86
  try:
87
+ print_info("Current mode: " ,mode)
88
+ config = get_config(environment)
89
+ # print(environment, host, port, mode, path, entry)
90
+ # return
91
+ if mode == 'production':
92
+ App = app.create(config=config)
93
+ App.run()
94
+ return
86
95
  aux_app = web.Application(
87
96
  logger=None,
88
97
  )
89
- config = get_config(environment)
90
98
  server = config.get("server", {})
91
99
  server = chainMap(server, {"host": host, "port": port, "path": path})
92
100
  config["server"] = server
93
101
 
94
102
  aux_port = int(server.port) + 1
95
- task = AppTask(Path(".").resolve(), config, entry=model)
103
+ task = AppTask(Path(".").resolve(), config, entry=entry)
96
104
  aux_app.cleanup_ctx.append(task.cleanup_ctx)
97
105
  web.run_app(
98
106
  aux_app,
@@ -102,8 +110,10 @@ def start(environment, host, port, path, model) -> None:
102
110
  print=None,
103
111
  shutdown_timeout=0.1,
104
112
  )
113
+ except KeyboardInterrupt:
114
+ sys.exit(0)
105
115
  except Exception as e:
106
- # error(e)
116
+ # print_error(e)
107
117
  print_error(traceback.format_exc())
108
118
  sys.exit(0)
109
119
 
@@ -107,7 +107,7 @@ class Client(object):
107
107
  self._server.sendmail(self._account, to_addr, msg.as_string())
108
108
  self._server.quit()
109
109
  except BaseException as er:
110
- error(er)
110
+ print_error(er)
111
111
 
112
112
  def add_to_addr(self, nick, addr):
113
113
  """
@@ -139,7 +139,7 @@ class Client(object):
139
139
  if len(mime_types) > 0:
140
140
  mime_type = mime_types[0]
141
141
  else:
142
- error("无法匹配附件类型,可以尝试安装httpd服务")
142
+ print_error("无法匹配附件类型,可以尝试安装httpd服务")
143
143
  ## 这里如果拿不到type 需要安装httpd ,dnf install httpd
144
144
  [t, n] = mime_type.split("/")
145
145
  filename = os.path.basename(filepath) # 'a.txt'
@@ -110,7 +110,7 @@ class Postgres(MeteBase):
110
110
  )
111
111
  print_info(f"Database connection successfuly for postgres/{kw.get('db')}")
112
112
  except Exception as e:
113
- # error(e)
113
+ # print_error(e)
114
114
  # print(traceback.format_exc())
115
115
  print_error(
116
116
  f"Database connection failed,the instance : postgres/{kw.get('db')}"
@@ -36,7 +36,7 @@ class MeteBase:
36
36
  # await fun(cursor)
37
37
  # await conn.commit()
38
38
  # except Exception as e:
39
- # error(e)
39
+ # print_error(e)
40
40
  # await conn.rollback()
41
41
  # finally:
42
42
  # if cursor:
@@ -30,7 +30,7 @@ from aiomysql.pool import Pool
30
30
 
31
31
  # from aiomysql.cursors import Cursor
32
32
  # from aiomysql.connection import Connection
33
- from cloudoll.logging import error, warning
33
+ from cloudoll.logging import print_error
34
34
 
35
35
  # from inspect import isclass, isfunction
36
36
  from .base import MeteBase
@@ -76,8 +76,9 @@ class Mysql(MeteBase):
76
76
  maxsize=kw.get("maxsize", 10),
77
77
  minsize=kw.get("pool_size", 5),
78
78
  cursorclass=AttrDictCursor,
79
+ connect_timeout=kw.get("connect_timeout", 10),
79
80
  loop=loop,
80
81
  )
81
82
  except Exception as e:
82
- error(f"Database connection failed,the instance : {kw.get('db')}")
83
+ print_error(f"Database connection failed,the instance : {kw.get('db')}")
83
84
  return self
@@ -53,10 +53,15 @@ class Postgres(MeteBase):
53
53
  dsn = f"dbname={db[0]} user={user[0]} password={password[0]} host={host[0]} port={port[0]}"
54
54
  self.pool = await create_pool(
55
55
  dsn=dsn,
56
- timeout=kw.get("timeout"),
56
+ timeout=kw.get("timeout", 10.0),
57
+ enable_json=kw.get("enable_json"),
58
+ enable_hstore=kw.get("enable_hstore"),
59
+ enable_uuid=kw.get("enable_uuid"),
60
+ enable_uuid=kw.get("enable_uuid"),
61
+ pool_recycle=kw.get("pool_recycle", 10),
57
62
  echo=kw.get("echo", False),
58
- maxsize=kw.get("maxsize", 10),
59
63
  minsize=kw.get("pool_size", 5),
64
+ maxsize=kw.get("pool_size", 10),
60
65
  )
61
66
  except Exception as e:
62
67
  # print_error(e)
@@ -7,7 +7,7 @@ __author__ = "chuchur/chuchur.com"
7
7
  import base64
8
8
  import hashlib
9
9
  import hmac
10
- import logging
10
+ from ..logging import print_error
11
11
  from curl_cffi import requests as http
12
12
  import time
13
13
  from urllib import parse
@@ -22,7 +22,7 @@ class Client(object):
22
22
  def _get_sign(self):
23
23
  secret = self._secret
24
24
  if not secret:
25
- logging.error("缺少secret")
25
+ print_error("缺少secret")
26
26
  return None, None
27
27
 
28
28
  # 拼接timestamp和secret
@@ -48,7 +48,7 @@ class Client(object):
48
48
  """
49
49
  access_token = self._access_token
50
50
  if not access_token:
51
- logging.error("请配置access_token")
51
+ print_error("请配置access_token")
52
52
  return False
53
53
  url = "https://oapi.dingtalk.com/media/upload?access_token=%s" % access_token
54
54
  with open(filepath, "rb") as f:
@@ -58,7 +58,7 @@ class Client(object):
58
58
  if res["errcode"] == 0:
59
59
  return res
60
60
  else:
61
- logging.error(res["errmsg"])
61
+ print_error(res["errmsg"])
62
62
 
63
63
  def send(self, data: dict):
64
64
  """
@@ -67,7 +67,7 @@ class Client(object):
67
67
  """
68
68
  webhook = self._webhook
69
69
  if not webhook:
70
- logging.error("缺少webhook")
70
+ print_error("缺少webhook")
71
71
  return False
72
72
  timestamp, sign = self._get_sign()
73
73
  if not timestamp or not sign:
@@ -82,11 +82,11 @@ class Client(object):
82
82
  if result:
83
83
  res = result.json()
84
84
  if res["errcode"] == 0:
85
- logging.info("发送成功!")
85
+ print_error("发送成功!")
86
86
  return True
87
87
  else:
88
- logging.info("发送失败")
89
- logging.error(res["errmsg"])
88
+ print_error("发送失败")
89
+ print_error(res["errmsg"])
90
90
  return False
91
91
 
92
92
  def send_text(self, text: str):
@@ -3,9 +3,9 @@
3
3
 
4
4
  __author__ = "chuchur/chuchur.com"
5
5
 
6
- import hashlib, hmac, time, base64, logging
6
+ import hashlib, hmac, time, base64
7
7
  from curl_cffi import requests as http
8
-
8
+ from ..logging import print_error,print_info
9
9
 
10
10
  class Client(object):
11
11
  def __init__(self, **kw):
@@ -15,7 +15,7 @@ class Client(object):
15
15
  def _get_sign(self):
16
16
  secret = self._secret
17
17
  if not secret:
18
- logging.error("缺少secret")
18
+ print_error("缺少secret")
19
19
  return None, None
20
20
  # 拼接timestamp和secret
21
21
  timestamp = int(time.time())
@@ -36,7 +36,7 @@ class Client(object):
36
36
  """
37
37
  webhook = self._webhook
38
38
  if not webhook:
39
- logging.error("缺少webhook")
39
+ print_error("缺少webhook")
40
40
  return False
41
41
  timestamp, sign = self._get_sign()
42
42
  if not timestamp or not sign:
@@ -48,10 +48,10 @@ class Client(object):
48
48
  if result:
49
49
  res = result.json()
50
50
  if res["StatusCode"] == 0:
51
- logging.info("发送成功")
51
+ print_info("发送成功")
52
52
  return False
53
53
  else:
54
- logging.info("发送失败!")
54
+ print_error("发送失败!")
55
55
  return True
56
56
 
57
57
  def send_text(self, text: str):
@@ -139,7 +139,9 @@ class AppTask(WatchTask):
139
139
  def _start_dev_server(self) -> None:
140
140
  act = "Start" if self._reloads == 0 else "Restart"
141
141
  print_info(f"{act}ing dev server")
142
- print_info(f"Server Running on http://0.0.0.0:{self._config['server']['port']}")
142
+ print_info(
143
+ f"Server Running on http://{self._config['server']['host']}:{self._config['server']['port']}"
144
+ )
143
145
 
144
146
  try:
145
147
  tty_path = os.ttyname(sys.stdin.fileno())
@@ -125,7 +125,7 @@ def _get_modules(fd):
125
125
  modules = set()
126
126
  temp = os.path.join(os.path.abspath("."), fd)
127
127
  if not os.path.exists(temp):
128
- info("Routers not detected")
128
+ print_info("Routers not detected")
129
129
  return modules
130
130
  s = find_packages(temp)
131
131
  for pkg in s:
@@ -170,7 +170,7 @@ def _reg_middleware():
170
170
  mid_dir = os.path.join(os.path.abspath("."), root)
171
171
  # print(mid_dir)
172
172
  if not os.path.exists(mid_dir):
173
- info("Middlewares not detected")
173
+ print_info("Middlewares not detected")
174
174
  return
175
175
  for f in os.listdir(mid_dir):
176
176
  if not f.startswith("__"):
@@ -387,7 +387,7 @@ class Application(object):
387
387
  :params prot default 9001
388
388
  :params host default 127.0.0.1
389
389
  """
390
- defaults = {"host": "127.0.0.1", "port": 9001, "path": None}
390
+ defaults = {"host": "0.0.0.0", "port": 9001, "path": None}
391
391
  conf = self.config.get("server", {})
392
392
  # args_conf = {"host": self.args.host, "port": self.args.port}
393
393
  # print(conf)
@@ -409,7 +409,7 @@ class Application(object):
409
409
  # if self.loop is None:
410
410
  # return web.run_app(self.app, host=host, port=port, **kw)
411
411
  # else:
412
- # logging.info(f"Server run at http://{host}:{port}")
412
+ # print_info(f"Server run at http://{host}:{port}")
413
413
  # return self.loop.create_server(
414
414
  # self.app.make_handler(), host=host, port=port, **kw
415
415
  # )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloudoll
3
- Version: 2.2.10
3
+ Version: 2.2.12
4
4
  Summary: 辅助快速创建可分布的微服务。
5
5
  Home-page: https://gitee.com/chuchur/cloudoll-py
6
6
  Author: chuchur
@@ -1,4 +1,4 @@
1
- requests
1
+ watchfilescurl_cffi
2
2
  colorlog
3
3
  aiomysql
4
4
  aiopg
@@ -24,7 +24,8 @@ VERSION = version.__version__
24
24
 
25
25
  # What packages are required for this module to be executed?
26
26
  REQUIRED = [
27
- "requests",
27
+ "watchfiles"
28
+ "curl_cffi",
28
29
  "colorlog",
29
30
  "aiomysql",
30
31
  "aiopg",
@@ -1 +0,0 @@
1
- __version__ = "2.2.10"
File without changes
File without changes
File without changes
File without changes
File without changes