gomyck-tools 1.2.8__tar.gz → 1.2.9__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 (67) hide show
  1. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/PKG-INFO +1 -1
  2. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/bottle_web_base.py +19 -18
  3. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/bottle_webserver.py +43 -14
  4. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/database.py +8 -0
  5. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/dict_wrapper.py +3 -1
  6. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/gomyck_tools.egg-info/PKG-INFO +1 -1
  7. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/setup.py +1 -1
  8. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/README.md +0 -0
  9. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/__init__.py +0 -0
  10. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/aes_tools.py +0 -0
  11. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/api_result.py +0 -0
  12. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/application.py +0 -0
  13. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/b64.py +0 -0
  14. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/bashPath.py +0 -0
  15. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/bottle_websocket.py +0 -0
  16. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/browser_element_tools.py +0 -0
  17. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/call.py +0 -0
  18. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/cftp.py +0 -0
  19. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/cjson.py +0 -0
  20. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/ckafka.py +0 -0
  21. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/compile_tools.py +0 -0
  22. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/console.py +0 -0
  23. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/coord_trans.py +0 -0
  24. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/credis.py +0 -0
  25. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/cron_lite.py +0 -0
  26. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/ctoken.py +0 -0
  27. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/czip.py +0 -0
  28. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/date_utils.py +0 -0
  29. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/douglas_rarefy.py +0 -0
  30. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/download_tools.py +0 -0
  31. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/enums.py +0 -0
  32. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/ex.py +0 -0
  33. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/excelOpt.py +0 -0
  34. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/html_soup.py +0 -0
  35. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/http_utils.py +0 -0
  36. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/images_tools.py +0 -0
  37. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/imgDialog.py +0 -0
  38. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/metrics.py +0 -0
  39. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/mqtt_utils.py +0 -0
  40. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/obj.py +0 -0
  41. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/pacth.py +0 -0
  42. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/plan_area_tools.py +0 -0
  43. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/process_pool.py +0 -0
  44. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/pty_tools.py +0 -0
  45. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/resource_bundle_tools.py +0 -0
  46. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/rsa.py +0 -0
  47. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/screenshot_tools.py +0 -0
  48. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/sign.py +0 -0
  49. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/sm_tools.py +0 -0
  50. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/snow_id.py +0 -0
  51. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/str_diff.py +0 -0
  52. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/string_tools.py +0 -0
  53. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/sys_info.py +0 -0
  54. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/sys_log.py +0 -0
  55. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/thread_pool.py +0 -0
  56. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/upload_tools.py +0 -0
  57. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/win_canvas.py +0 -0
  58. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/win_control.py +0 -0
  59. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/wordFill.py +0 -0
  60. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/word_fill.py +0 -0
  61. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/word_fill_entity.py +0 -0
  62. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/ctools/work_path.py +0 -0
  63. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/gomyck_tools.egg-info/SOURCES.txt +0 -0
  64. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/gomyck_tools.egg-info/dependency_links.txt +0 -0
  65. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/gomyck_tools.egg-info/requires.txt +0 -0
  66. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/gomyck_tools.egg-info/top_level.txt +0 -0
  67. {gomyck-tools-1.2.8 → gomyck_tools-1.2.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gomyck-tools
3
- Version: 1.2.8
3
+ Version: 1.2.9
4
4
  Summary: A tools collection for python development by hao474798383
5
5
  Home-page: https://blog.gomyck.com
6
6
  Author: gomyck
@@ -123,18 +123,30 @@ def params_resolve(func):
123
123
  queryStr.page_info = page_info
124
124
  return func(params=queryStr, *args, **kwargs)
125
125
  elif request.method == 'POST':
126
+ query_params = request.query.decode('utf-8')
126
127
  content_type = request.get_header('content-type')
127
128
  if content_type == 'application/json':
128
129
  params = request.json or {}
129
- return func(params=DictWrapper(params), *args, **kwargs)
130
- elif content_type and 'multipart/form-data' in content_type:
130
+ dict_wrapper = DictWrapper(params)
131
+ dict_wrapper.query_params = query_params
132
+ return func(params=dict_wrapper, *args, **kwargs)
133
+ elif 'multipart/form-data' in content_type:
131
134
  form_data = request.forms.decode()
132
135
  form_files = request.files.decode()
133
- params = FormDataParams(data=DictWrapper(form_data), files=form_files)
134
- return func(params=params, *args, **kwargs)
135
- else:
136
- params = request.query.decode('utf-8')
137
- return func(params=params, *args, **kwargs)
136
+ dict_wrapper = DictWrapper(form_data)
137
+ dict_wrapper.query_params = query_params
138
+ dict_wrapper.files = form_files
139
+ return func(params=dict_wrapper, *args, **kwargs)
140
+ elif 'application/x-www-form-urlencoded' in content_type:
141
+ params = request.forms.decode()
142
+ dict_wrapper = DictWrapper(params.dict)
143
+ dict_wrapper.query_params = query_params
144
+ return func(params=dict_wrapper, *args, **kwargs)
145
+ elif 'text/plain' in content_type:
146
+ params = request.body.read().decode('utf-8')
147
+ dict_wrapper = DictWrapper({'body': params})
148
+ dict_wrapper.query_params = query_params
149
+ return func(params=dict_wrapper, *args, **kwargs)
138
150
  else:
139
151
  return func(*args, **kwargs)
140
152
  return decorated
@@ -144,17 +156,6 @@ class PageInfo:
144
156
  self.page_size = page_size
145
157
  self.page_index = page_index
146
158
 
147
- class FormDataParams:
148
- def __init__(self, data, files):
149
- self.data = data
150
- self.files = files
151
-
152
- def __getattr__(self, key):
153
- try:
154
- return self.data[key]
155
- except Exception:
156
- return self.files[key]
157
-
158
159
  # 通用的鉴权方法
159
160
  def common_auth_verify(aes_key):
160
161
  if request.path.startswith('/static') or request.path in GlobalState.withOutLoginURI:
@@ -2,7 +2,7 @@ import sys
2
2
  from socketserver import ThreadingMixIn
3
3
  from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, make_server
4
4
 
5
- from bottle import ServerAdapter, Bottle, template, static_file, abort, redirect
5
+ from bottle import ServerAdapter, Bottle, template, static_file, abort, redirect, response
6
6
 
7
7
  from ctools import sys_info
8
8
 
@@ -56,34 +56,63 @@ class CBottle:
56
56
  self.port = port
57
57
  self.quiet = quiet
58
58
  self.bottle = bottle
59
+ self.index_root = './'
60
+ self.index_filename = 'index.html'
61
+ self.is_tpl = False
62
+ self.tmp_args = {}
63
+ self.redirect_url = None
64
+ self.static_root = './static'
65
+ self.download_root = './download'
59
66
 
60
- def run(self):
61
- http_server = WSGIRefServer(port=self.port)
62
- print('Click the link below to open the service homepage %s' % '\n \t\t http://localhost:%s \n \t\t http://%s:%s' % (self.port, sys_info.get_local_ipv4(), self.port), file=sys.stderr)
63
- self.bottle.run(server=http_server, quiet=self.quiet)
64
-
65
- def set_index(self, root='./', filename='index.html', is_tpl=False, redirect_url=None, **kwargs):
66
67
  @self.bottle.route(['/', '/index'])
67
68
  def index():
68
69
  try:
69
- if redirect_url: return redirect(redirect_url)
70
- if is_tpl: return template(f"{root}/{filename}", **kwargs)
71
- return static_file(filename=filename, root=root, **kwargs)
70
+ if self.redirect_url: return redirect(self.redirect_url)
71
+ if self.is_tpl: return template(f"{self.index_root}/{self.index_filename}", self.tmp_args)
72
+ return static_file(filename=self.index_filename, root=self.index_root)
72
73
  except FileNotFoundError:
73
74
  abort(404, "File not found...")
74
75
 
75
- def set_static(self, root):
76
76
  @self.bottle.route('/static/<filepath:path>')
77
77
  def static(filepath):
78
78
  try:
79
- return static_file(filepath, root=root)
79
+ return static_file(filepath, root=self.static_root)
80
80
  except FileNotFoundError:
81
81
  abort(404, "File not found...")
82
82
 
83
- def set_download(self, root):
84
83
  @self.bottle.route('/download/<filepath:path>')
85
84
  def download(filepath):
86
- return static_file(filepath, root=root, download=True)
85
+ return static_file(filepath, root=self.download_root, download=True)
86
+
87
+ @self.bottle.route('/favicon.ico')
88
+ def favicon():
89
+ response.content_type = 'image/svg+xml'
90
+ svg_icon = '''<?xml version="1.0" encoding="UTF-8"?>
91
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
92
+ <circle cx="16" cy="16" r="14" fill="#007bff"/>
93
+ <path d="M16 8a8 8 0 0 0-8 8h2a6 6 0 0 1 12 0h2a8 8 0 0 0-8-8z" fill="white"/>
94
+ <circle cx="16" cy="20" r="2" fill="white"/>
95
+ </svg>
96
+ '''
97
+ return svg_icon
98
+
99
+ def run(self):
100
+ http_server = WSGIRefServer(port=self.port)
101
+ print('Click the link below to open the service homepage %s' % '\n \t\t http://localhost:%s \n \t\t http://%s:%s' % (self.port, sys_info.get_local_ipv4(), self.port), file=sys.stderr)
102
+ self.bottle.run(server=http_server, quiet=self.quiet)
103
+
104
+ def set_index(self, filename='index.html', root='./', is_tpl=False, redirect_url=None, **kwargs):
105
+ self.index_root = root
106
+ self.index_filename = filename
107
+ self.is_tpl = is_tpl
108
+ self.redirect_url = redirect_url
109
+ self.tmp_args = kwargs
110
+
111
+ def set_static(self, root='./static'):
112
+ self.static_root = root
113
+
114
+ def set_download(self, root='./download'):
115
+ self.download_root = root
87
116
 
88
117
  def mount(self, context_path, app, **kwargs):
89
118
  self.bottle.mount(context_path, app, **kwargs)
@@ -11,6 +11,13 @@ from ctools import call, string_tools
11
11
  from ctools.thread_pool import thread_local
12
12
 
13
13
  """
14
+ class XXXX(BaseMixin):
15
+ __tablename__ = 't_xxx_info'
16
+ __table_args__ = {'comment': 'xxx信息表'}
17
+ server_content: Column = Column(String(50), nullable=True, default='', comment='123123')
18
+ server_ip: Column = Column(String(30), index=True)
19
+ user_id: Column = Column(BigInteger)
20
+
14
21
  database.init_db('postgresql://postgres:123456@192.168.3.107:32566/abc', default_schema='public', db_key='source', pool_size=100)
15
22
  with database.get_session('source') as s:
16
23
  s.execute(text('insert into xxx (name) values (:name)'), {'name': string_tools.get_random_str(5)})
@@ -56,6 +63,7 @@ def init_db(db_url: str, db_key: str='default', connect_args: dict={}, default_s
56
63
  sessionMakers[db_key] = sessionMaker
57
64
  inited_db[db_key] = True
58
65
  if default_schema: event.listen(engine, 'connect', lambda dbapi_connection, connection_record: _set_search_path(dbapi_connection, default_schema))
66
+ Base.metadata.create_all(engine)
59
67
 
60
68
  def _set_search_path(dbapi_connection, default_schema):
61
69
  with dbapi_connection.cursor() as cursor:
@@ -7,7 +7,9 @@ class DictWrapper(dict):
7
7
  def __getattr__(self, key):
8
8
  res = self.get(key)
9
9
  if res is None:
10
- raise AttributeError(f"'{key}' not found in this Entity")
10
+ res = self.query_params.get(key)
11
+ if res is None:
12
+ raise AttributeError(f" ==>> {key} <<== Not Found In This Entity!!!")
11
13
  if isinstance(res, dict):
12
14
  return DictWrapper(res)
13
15
  return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gomyck-tools
3
- Version: 1.2.8
3
+ Version: 1.2.9
4
4
  Summary: A tools collection for python development by hao474798383
5
5
  Home-page: https://blog.gomyck.com
6
6
  Author: gomyck
@@ -11,7 +11,7 @@ requirements = parse_requirements(os.path.join(os.path.dirname(__file__), 'requi
11
11
 
12
12
  setup(
13
13
  name="gomyck-tools",
14
- version="1.2.8",
14
+ version="1.2.9",
15
15
  author="gomyck",
16
16
  author_email="hao474798383@163.com",
17
17
  description="A tools collection for python development by hao474798383",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes