pytbox 20250818.2__tar.gz → 20250818.4__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.
Potentially problematic release.
This version of pytbox might be problematic. Click here for more details.
- {pytbox-20250818.2 → pytbox-20250818.4}/PKG-INFO +2 -2
- {pytbox-20250818.2 → pytbox-20250818.4}/README.md +1 -1
- {pytbox-20250818.2 → pytbox-20250818.4}/pyproject.toml +1 -1
- pytbox-20250818.4/src/pytbox/dida365.py +0 -0
- pytbox-20250818.4/src/pytbox/utils/timeutils.py +36 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox.egg-info/PKG-INFO +2 -2
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox.egg-info/SOURCES.txt +0 -1
- pytbox-20250818.2/src/pytbox/common/base.py +0 -44
- pytbox-20250818.2/src/pytbox/timeutils.py +0 -1
- pytbox-20250818.2/src/pytbox/utils/timeutils.py +0 -23
- {pytbox-20250818.2 → pytbox-20250818.4}/setup.cfg +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox/common/__init__.py +0 -0
- /pytbox-20250818.2/src/pytbox/dida365.py → /pytbox-20250818.4/src/pytbox/common/base.py +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox/utils/response.py +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox/victoriametrics.py +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox.egg-info/dependency_links.txt +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox.egg-info/requires.txt +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/src/pytbox.egg-info/top_level.txt +0 -0
- {pytbox-20250818.2 → pytbox-20250818.4}/tests/test_victoriametrics.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytbox
|
|
3
|
-
Version: 20250818.
|
|
3
|
+
Version: 20250818.4
|
|
4
4
|
Summary: A collection of Python integrations and utilities (Feishu, Dida365, VictoriaMetrics, ...)
|
|
5
5
|
Author-email: mingming hou <houm01@foxmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -255,7 +255,7 @@ ruff check src/ tests/
|
|
|
255
255
|
如有问题或建议,请通过以下方式联系:
|
|
256
256
|
|
|
257
257
|
- 提交 [Issue](https://github.com/your-username/pytbox/issues)
|
|
258
|
-
- 发送邮件至
|
|
258
|
+
- 发送邮件至 houm01@foxmail.com
|
|
259
259
|
|
|
260
260
|
---
|
|
261
261
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pytbox"
|
|
7
|
-
version = "20250818.
|
|
7
|
+
version = "20250818.4"
|
|
8
8
|
description = "A collection of Python integrations and utilities (Feishu, Dida365, VictoriaMetrics, ...)"
|
|
9
9
|
authors = [{ name = "mingming hou", email = "houm01@foxmail.com" }]
|
|
10
10
|
license = { text = "MIT" }
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import time
|
|
5
|
+
import pytz
|
|
6
|
+
import datetime
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TimeUtils:
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
def get_timestamp(now: bool=True) -> int:
|
|
13
|
+
'''
|
|
14
|
+
获取时间戳
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
now (bool, optional): _description_. Defaults to True.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
_type_: _description_
|
|
21
|
+
'''
|
|
22
|
+
if now:
|
|
23
|
+
return int(time.time())
|
|
24
|
+
else:
|
|
25
|
+
return int(time.time() * 1000)
|
|
26
|
+
|
|
27
|
+
@staticmethod
|
|
28
|
+
def get_time_object(now: bool=True):
|
|
29
|
+
'''
|
|
30
|
+
获取当前时间, 加入了时区信息, 简单是存储在 Mongo 中时格式为 ISODate
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
current_time(class): 时间, 格式: 2024-04-23 16:48:11.591589+08:00
|
|
34
|
+
'''
|
|
35
|
+
if now:
|
|
36
|
+
return datetime.datetime.now(pytz.timezone('Asia/Shanghai'))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytbox
|
|
3
|
-
Version: 20250818.
|
|
3
|
+
Version: 20250818.4
|
|
4
4
|
Summary: A collection of Python integrations and utilities (Feishu, Dida365, VictoriaMetrics, ...)
|
|
5
5
|
Author-email: mingming hou <houm01@foxmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -255,7 +255,7 @@ ruff check src/ tests/
|
|
|
255
255
|
如有问题或建议,请通过以下方式联系:
|
|
256
256
|
|
|
257
257
|
- 提交 [Issue](https://github.com/your-username/pytbox/issues)
|
|
258
|
-
- 发送邮件至
|
|
258
|
+
- 发送邮件至 houm01@foxmail.com
|
|
259
259
|
|
|
260
260
|
---
|
|
261
261
|
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Base classes and common utilities
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from ..utils.timeutils import TimeUtils
|
|
6
|
-
from typing import Dict, Any
|
|
7
|
-
import json
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class BaseAPI:
|
|
11
|
-
"""API基类,提供通用功能"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, base_url: str = ""):
|
|
14
|
-
self.base_url = base_url
|
|
15
|
-
self._session_created_at = TimeUtils.get_timestamp()
|
|
16
|
-
|
|
17
|
-
def get_session_age(self) -> int:
|
|
18
|
-
"""获取会话存活时间(秒)"""
|
|
19
|
-
current_time = TimeUtils.get_timestamp()
|
|
20
|
-
return current_time - self._session_created_at
|
|
21
|
-
|
|
22
|
-
def log_request(self, method: str, url: str, data: Dict[Any, Any] = None) -> str:
|
|
23
|
-
"""记录请求日志"""
|
|
24
|
-
timestamp = TimeUtils.get_timestamp()
|
|
25
|
-
log_entry = {
|
|
26
|
-
"timestamp": timestamp,
|
|
27
|
-
"method": method,
|
|
28
|
-
"url": url,
|
|
29
|
-
"data": data or {}
|
|
30
|
-
}
|
|
31
|
-
return json.dumps(log_entry, ensure_ascii=False)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class BaseResponse:
|
|
35
|
-
"""响应基类"""
|
|
36
|
-
|
|
37
|
-
def __init__(self, data: Dict[Any, Any]):
|
|
38
|
-
self.data = data
|
|
39
|
-
self.created_at = TimeUtils.get_timestamp()
|
|
40
|
-
|
|
41
|
-
def is_expired(self, ttl_seconds: int = 3600) -> bool:
|
|
42
|
-
"""检查响应是否过期"""
|
|
43
|
-
current_time = TimeUtils.get_timestamp()
|
|
44
|
-
return (current_time - self.created_at) > ttl_seconds
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import time
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class TimeUtils:
|
|
8
|
-
|
|
9
|
-
@staticmethod
|
|
10
|
-
def get_timestamp(now: bool=True) -> int:
|
|
11
|
-
'''
|
|
12
|
-
获取时间戳
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
now (bool, optional): _description_. Defaults to True.
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
_type_: _description_
|
|
19
|
-
'''
|
|
20
|
-
if now:
|
|
21
|
-
return int(time.time())
|
|
22
|
-
else:
|
|
23
|
-
return int(time.time() * 1000)
|
|
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
|