cloudoll 3.0.0__tar.gz → 3.0.1__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 (44) hide show
  1. {cloudoll-3.0.0 → cloudoll-3.0.1}/PKG-INFO +4 -4
  2. cloudoll-3.0.1/cloudoll/__init__.py +1 -0
  3. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/requests.py +45 -47
  4. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll.egg-info/PKG-INFO +4 -4
  5. {cloudoll-3.0.0 → cloudoll-3.0.1}/pyproject.toml +3 -3
  6. {cloudoll-3.0.0 → cloudoll-3.0.1}/setup.cfg +1 -1
  7. cloudoll-3.0.0/cloudoll/__init__.py +0 -1
  8. {cloudoll-3.0.0 → cloudoll-3.0.1}/LICENSE +0 -0
  9. {cloudoll-3.0.0 → cloudoll-3.0.1}/README.md +0 -0
  10. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/__main__.py +0 -0
  11. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/cli.py +0 -0
  12. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/clitool/__init__.py +0 -0
  13. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/clitool/cli_main.py +0 -0
  14. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/clitool/m2d.py +0 -0
  15. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/clitool/process.py +0 -0
  16. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/clitool/spinner.py +0 -0
  17. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/clitool/watch.py +0 -0
  18. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/logging/__init__.py +0 -0
  19. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/mail/__init__.py +0 -0
  20. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/mail/smtp.py +0 -0
  21. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/__init__.py +0 -0
  22. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/base.py +0 -0
  23. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/err.py +0 -0
  24. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/field.py +0 -0
  25. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/model.py +0 -0
  26. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/mysql.py +0 -0
  27. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/parse.py +0 -0
  28. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/orm/postgres.py +0 -0
  29. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/template/__init__.py +0 -0
  30. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/utils/__init__.py +0 -0
  31. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/utils/common.py +0 -0
  32. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/utils/snowflake.py +0 -0
  33. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/__init__.py +0 -0
  34. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/core.py +0 -0
  35. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/exception.py +0 -0
  36. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/html.py +0 -0
  37. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/jwt.py +0 -0
  38. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll/web/settings.py +0 -0
  39. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll.egg-info/SOURCES.txt +0 -0
  40. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll.egg-info/dependency_links.txt +0 -0
  41. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll.egg-info/entry_points.txt +0 -0
  42. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll.egg-info/requires.txt +0 -0
  43. {cloudoll-3.0.0 → cloudoll-3.0.1}/cloudoll.egg-info/top_level.txt +0 -0
  44. {cloudoll-3.0.0 → cloudoll-3.0.1}/setup.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudoll
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: Assist in quickly creating distributable microservices based on aiohttp, with a focus on simplicity and ease of use.
5
- Home-page: https://gitee.com/chuchur/cloudoll-py
5
+ Home-page: https://github.com/smallerqiu/cloudoll-py
6
6
  Author: Qiu
7
7
  Author-email: Qiu <smallerqiu@gmail.com>
8
8
  License-Expression: MIT
9
- Project-URL: Homepage, https://gitee.com/chuchur/cloudoll-py
10
- Project-URL: Repository, https://gitee.com/chuchur/cloudoll-py
9
+ Project-URL: Homepage, https://github.com/smallerqiu/cloudoll-py
10
+ Project-URL: Repository, https://github.com/smallerqiu/cloudoll-py
11
11
  Keywords: Microservices,aiohttp,cloudoll
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.6
@@ -0,0 +1 @@
1
+ __version__ = "3.0.1"
@@ -1,28 +1,38 @@
1
1
  import aiohttp
2
2
  import asyncio
3
- from typing import Optional, Dict, Any, Union
3
+ # import ssl
4
+ from typing import Optional, Dict, Union, List, Any
5
+
6
+ JSONType = Union[Dict[str, Any], List[Any], str, int, float, bool, None]
4
7
 
5
8
 
6
9
  class AsyncRequest:
7
10
  def __init__(
8
11
  self,
9
- timeout: int = 30,
10
- max_retries: int = 3,
12
+ timeout: float = 30.0,
13
+ max_retries: int = 1,
11
14
  retry_delay: float = 1.0,
12
- session: Optional[aiohttp.ClientSession] = None,
15
+ keep_alive: bool = True,
16
+ use_cookies: bool = False,
17
+ proxy: Optional[str] = None,
18
+ # session: Optional[aiohttp.ClientSession] = None,
19
+ # connector: Optional[aiohttp.BaseConnector] = None,
20
+ # ssl: Union[bool, ssl.SSLContext] = True,
13
21
  ):
14
- """
15
- Asynchronous HTTP request client
16
-
17
- :param timeout: Request timeout(Second)
18
- :param max_retries: Maximum retry attempts
19
- :param retry_delay: Retry delay(Second)
20
- :param session: Reusable aiohttp session
21
- """
22
- self.timeout = aiohttp.ClientTimeout(total=timeout)
22
+ self.timeout = timeout
23
23
  self.max_retries = max_retries
24
24
  self.retry_delay = retry_delay
25
- self._session = session
25
+ # self.session = session
26
+ # self.connector = connector
27
+ self.use_cookies = use_cookies
28
+ self.keep_alive = keep_alive
29
+
30
+ self.session = aiohttp.ClientSession(
31
+ proxy=proxy,
32
+ connector=aiohttp.TCPConnector(keepalive_timeout=self.timeout) if self.keep_alive else None,
33
+ timeout=aiohttp.ClientTimeout(total=self.timeout),
34
+ cookie_jar=aiohttp.CookieJar() if self.use_cookies else None,
35
+ )
26
36
 
27
37
  async def request(
28
38
  self,
@@ -30,32 +40,19 @@ class AsyncRequest:
30
40
  url: str,
31
41
  params: Optional[Dict[str, Any]] = None,
32
42
  data: Optional[Union[Dict[str, Any], str, bytes]] = None,
33
- json_data: Optional[Any] = None,
43
+ json_data: Optional[JSONType] = None,
34
44
  headers: Optional[Dict[str, str]] = None,
35
45
  cookies: Optional[Dict[str, str]] = None,
36
46
  allow_redirects: bool = True,
37
47
  raise_for_status: bool = True,
38
- ) -> aiohttp.ClientResponse:
39
- """
40
- Perform asynchronous HTTP requests
41
-
42
- :param method: HTTP方法 (GET, POST, PUT, DELETE等)
43
- :param url: Request URL
44
- :param params: URL query parameters
45
- :param data: Request body data (Forms or raw data)
46
- :param json_data: JSON formatted request body data
47
- :param headers: Request headers
48
- :param cookies: Cookies
49
- :param allow_redirects: Whether to allow redirects
50
- :param raise_for_status: Whether to raise an exception for HTTP errors
51
- :return: aiohttp.ClientResponse
52
- """
53
- session = self._session or aiohttp.ClientSession(timeout=self.timeout)
48
+ proxy: Optional[str] = None,
49
+ # parse_json: bool = False,
50
+ ) -> Union[dict, str, aiohttp.ClientResponse]:
54
51
  last_exception = None
55
52
 
56
53
  for attempt in range(self.max_retries):
57
54
  try:
58
- async with session.request(
55
+ response = await self.session.request(
59
56
  method=method,
60
57
  url=url,
61
58
  params=params,
@@ -64,28 +61,29 @@ class AsyncRequest:
64
61
  headers=headers,
65
62
  cookies=cookies,
66
63
  allow_redirects=allow_redirects,
67
- ) as response:
68
- if raise_for_status:
69
- response.raise_for_status()
70
- return response
64
+ proxy=proxy,
65
+ )
66
+ return response
71
67
 
72
68
  except (aiohttp.ClientError, asyncio.TimeoutError) as e:
73
69
  last_exception = e
74
70
  if attempt < self.max_retries - 1:
75
71
  await asyncio.sleep(self.retry_delay * (attempt + 1))
76
72
  continue
73
+ # finally:
74
+ # if use_temp_session:
75
+ # await session.close()
77
76
 
78
- if self._session is None:
79
- await session.close()
80
-
81
- raise last_exception or RuntimeError("Request failed")
77
+ raise last_exception or RuntimeError(
78
+ f"Request failed after {self.max_retries} attempts"
79
+ )
82
80
 
83
81
  async def get(
84
82
  self,
85
83
  url: str,
86
84
  params: Optional[Dict[str, Any]] = None,
87
85
  headers: Optional[Dict[str, str]] = None,
88
- **kwargs
86
+ **kwargs,
89
87
  ) -> aiohttp.ClientResponse:
90
88
  """Send a GET request"""
91
89
  return await self.request("GET", url, params=params, headers=headers, **kwargs)
@@ -96,7 +94,7 @@ class AsyncRequest:
96
94
  data: Optional[Union[Dict[str, Any], str, bytes]] = None,
97
95
  json_data: Optional[Any] = None,
98
96
  headers: Optional[Dict[str, str]] = None,
99
- **kwargs
97
+ **kwargs,
100
98
  ) -> aiohttp.ClientResponse:
101
99
  """Send a POST request"""
102
100
  return await self.request(
@@ -109,7 +107,7 @@ class AsyncRequest:
109
107
  data: Optional[Union[Dict[str, Any], str, bytes]] = None,
110
108
  json_data: Optional[Any] = None,
111
109
  headers: Optional[Dict[str, str]] = None,
112
- **kwargs
110
+ **kwargs,
113
111
  ) -> aiohttp.ClientResponse:
114
112
  """Send a PUT request"""
115
113
  return await self.request(
@@ -123,10 +121,10 @@ class AsyncRequest:
123
121
  return await self.request("DELETE", url, headers=headers, **kwargs)
124
122
 
125
123
  async def close(self) -> None:
126
- """Close the aiohttp session if it exists """
127
- if self._session is not None:
128
- await self._session.close()
129
- self._session = None
124
+ """Close the aiohttp session if it exists"""
125
+ if self.session is not None:
126
+ await self.session.close()
127
+ self.session = None
130
128
 
131
129
  async def __aenter__(self):
132
130
  return self
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudoll
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: Assist in quickly creating distributable microservices based on aiohttp, with a focus on simplicity and ease of use.
5
- Home-page: https://gitee.com/chuchur/cloudoll-py
5
+ Home-page: https://github.com/smallerqiu/cloudoll-py
6
6
  Author: Qiu
7
7
  Author-email: Qiu <smallerqiu@gmail.com>
8
8
  License-Expression: MIT
9
- Project-URL: Homepage, https://gitee.com/chuchur/cloudoll-py
10
- Project-URL: Repository, https://gitee.com/chuchur/cloudoll-py
9
+ Project-URL: Homepage, https://github.com/smallerqiu/cloudoll-py
10
+ Project-URL: Repository, https://github.com/smallerqiu/cloudoll-py
11
11
  Keywords: Microservices,aiohttp,cloudoll
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.6
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cloudoll"
7
- version = "3.0.0"
7
+ version = "3.0.1"
8
8
  description = "Assist in quickly creating distributable microservices based on aiohttp, with a focus on simplicity and ease of use."
9
9
  authors = [
10
10
  {name = "Qiu", email = "smallerqiu@gmail.com"},
@@ -39,8 +39,8 @@ dependencies = [
39
39
  ]
40
40
 
41
41
  [project.urls]
42
- Homepage = "https://gitee.com/chuchur/cloudoll-py"
43
- Repository = "https://gitee.com/chuchur/cloudoll-py"
42
+ Homepage = "https://github.com/smallerqiu/cloudoll-py"
43
+ Repository = "https://github.com/smallerqiu/cloudoll-py"
44
44
 
45
45
  [project.scripts]
46
46
  cloudoll = "cloudoll.cli:cli"
@@ -6,7 +6,7 @@ long_description = file: README.md
6
6
  long_description_content_type = text/markdown
7
7
  author = Qiu
8
8
  author_email = smallerqiu@gmail.com
9
- url = https://gitee.com/chuchur/cloudoll-py
9
+ url = https://github.com/smallerqiu/cloudoll-py
10
10
 
11
11
  [options]
12
12
  packages = find:
@@ -1 +0,0 @@
1
- __version__ = "3.0.0"
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