pymecli 0.5.8__tar.gz → 0.6.0__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.
- {pymecli-0.5.8 → pymecli-0.6.0}/PKG-INFO +3 -3
- {pymecli-0.5.8 → pymecli-0.6.0}/README.md +2 -2
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/bitget.py +1 -1
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/fast.py +2 -1
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/gate.py +1 -1
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/okx.py +1 -1
- {pymecli-0.5.8 → pymecli-0.6.0}/core/config.py +0 -1
- {pymecli-0.5.8 → pymecli-0.6.0}/pyproject.toml +1 -1
- pymecli-0.6.0/utils/pyredis.py +45 -0
- pymecli-0.5.8/utils/pyredis.py +0 -18
- {pymecli-0.5.8 → pymecli-0.6.0}/.gitignore +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/api/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/api/v1/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/api/v1/clash.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/api/v1/redis.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/dst.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/etcd_mysql.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/example.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/redis_csv.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/tele.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/cli/util.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/core/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/core/clash.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/core/redis_client.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/crypto/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/crypto/bitget.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/crypto/gate.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/crypto/okx.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/data/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/data/dou_dict.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/data/dou_list.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/data/main.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/data/template.yaml +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/models/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/models/douzero_model.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/models/ocr_model.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/models/response.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/__init__.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/elapsed.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/etcd.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/helper.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/logger.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/mysql.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/path.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/pd.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/sleep.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/text.py +0 -0
- {pymecli-0.5.8 → pymecli-0.6.0}/utils/toml.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pymecli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: My CLI
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/pymecli
|
|
6
6
|
Project-URL: Repository, https://github.com/meme2046/pymecli
|
|
@@ -67,8 +67,8 @@ uv run dst cml d:/.backups/dontstarvetogether/modoverrides.lua -m 3486375086
|
|
|
67
67
|
# etcdsync
|
|
68
68
|
|
|
69
69
|
```shell
|
|
70
|
-
etcdsync etcd2mysql /
|
|
70
|
+
etcdsync etcd2mysql /cron/jobs -e d:/.env/pymecli.env -t kvs
|
|
71
71
|
etcdsync etcd2mysql "" -e d:/.env/pymecli.env -t kvs # 全量
|
|
72
|
-
etcdsync mysql2etcd /
|
|
72
|
+
etcdsync mysql2etcd /cron/jobs -e d:/.env/pymecli.env -t kvs
|
|
73
73
|
etcdsync mysql2etcd -e d:/.env/pymecli.env -t kvs # 全量
|
|
74
74
|
```
|
|
@@ -28,8 +28,8 @@ uv run dst cml d:/.backups/dontstarvetogether/modoverrides.lua -m 3486375086
|
|
|
28
28
|
# etcdsync
|
|
29
29
|
|
|
30
30
|
```shell
|
|
31
|
-
etcdsync etcd2mysql /
|
|
31
|
+
etcdsync etcd2mysql /cron/jobs -e d:/.env/pymecli.env -t kvs
|
|
32
32
|
etcdsync etcd2mysql "" -e d:/.env/pymecli.env -t kvs # 全量
|
|
33
|
-
etcdsync mysql2etcd /
|
|
33
|
+
etcdsync mysql2etcd /cron/jobs -e d:/.env/pymecli.env -t kvs
|
|
34
34
|
etcdsync mysql2etcd -e d:/.env/pymecli.env -t kvs # 全量
|
|
35
35
|
```
|
|
@@ -13,13 +13,14 @@ from api.v1 import api_router
|
|
|
13
13
|
from core.clash import ClashConfig, init_generator
|
|
14
14
|
from core.config import settings
|
|
15
15
|
from models.response import SuccessResponse
|
|
16
|
+
from utils.pyredis import prepare_redis_url
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
@asynccontextmanager
|
|
19
20
|
async def lifespan(app: FastAPI):
|
|
20
21
|
"""管理应用生命周期的上下文管理器"""
|
|
21
22
|
redis_pool = redis.ConnectionPool.from_url(
|
|
22
|
-
settings.REDIS_URL,
|
|
23
|
+
prepare_redis_url(settings.REDIS_URL),
|
|
23
24
|
max_connections=20, # 根据需要调整最大连接数
|
|
24
25
|
decode_responses=True,
|
|
25
26
|
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from urllib.parse import urlsplit, urlunsplit
|
|
3
|
+
|
|
4
|
+
import redis as redis_sync
|
|
5
|
+
import redis.asyncio as redis
|
|
6
|
+
from dotenv import load_dotenv
|
|
7
|
+
|
|
8
|
+
DEFAULT_REDIS_URL = "redis://192.168.123.7:6379/0"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def prepare_redis_url(url: str) -> str:
|
|
12
|
+
"""规范化 Redis URL,追加 protocol=2 兼容 Redis 7"""
|
|
13
|
+
if "protocol=" in url:
|
|
14
|
+
return url
|
|
15
|
+
parts = urlsplit(url)
|
|
16
|
+
query = parts.query + ("&" if parts.query else "") + "protocol=2"
|
|
17
|
+
return urlunsplit((parts.scheme, parts.netloc, parts.path, query, ""))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# 向后兼容别名
|
|
21
|
+
_force_resp2 = prepare_redis_url
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_redis_client(
|
|
25
|
+
url: str | None = None,
|
|
26
|
+
decode_responses: bool = True,
|
|
27
|
+
env_path: str = ".env",
|
|
28
|
+
) -> redis.Redis:
|
|
29
|
+
load_dotenv(env_path)
|
|
30
|
+
redis_url = url or os.getenv("REDIS_URL", DEFAULT_REDIS_URL)
|
|
31
|
+
return redis.Redis.from_url(
|
|
32
|
+
_force_resp2(redis_url), decode_responses=decode_responses
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def get_redis_client_sync(
|
|
37
|
+
url: str | None = None,
|
|
38
|
+
decode_responses: bool = True,
|
|
39
|
+
env_path: str = ".env",
|
|
40
|
+
) -> redis_sync.Redis:
|
|
41
|
+
load_dotenv(env_path)
|
|
42
|
+
redis_url = url or os.getenv("REDIS_URL", DEFAULT_REDIS_URL)
|
|
43
|
+
return redis_sync.Redis.from_url(
|
|
44
|
+
_force_resp2(redis_url), decode_responses=decode_responses
|
|
45
|
+
)
|
pymecli-0.5.8/utils/pyredis.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
import redis as redis_sync
|
|
4
|
-
import redis.asyncio as redis
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def get_redis_client(
|
|
8
|
-
url: str = os.getenv("REDIS_URL", "redis://192.168.123.7:6379/0"),
|
|
9
|
-
decode_responses: bool = True,
|
|
10
|
-
) -> redis.Redis:
|
|
11
|
-
return redis.Redis.from_url(url, decode_responses=decode_responses)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def get_redis_client_sync(
|
|
15
|
-
url: str = os.getenv("REDIS_URL", "redis://192.168.123.7:6379/0"),
|
|
16
|
-
decode_responses: bool = True,
|
|
17
|
-
) -> redis_sync.Redis:
|
|
18
|
-
return redis_sync.Redis.from_url(url, decode_responses=decode_responses)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|