pymecli 0.5.7__tar.gz → 0.5.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.
- {pymecli-0.5.7 → pymecli-0.5.9}/PKG-INFO +3 -3
- {pymecli-0.5.7 → pymecli-0.5.9}/README.md +2 -2
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/bitget.py +11 -9
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/fast.py +2 -1
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/gate.py +6 -4
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/okx.py +7 -5
- {pymecli-0.5.7 → pymecli-0.5.9}/pyproject.toml +1 -1
- pymecli-0.5.9/utils/pyredis.py +45 -0
- pymecli-0.5.7/utils/pyredis.py +0 -18
- {pymecli-0.5.7 → pymecli-0.5.9}/.gitignore +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/api/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/api/v1/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/api/v1/clash.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/api/v1/redis.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/dst.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/etcd_mysql.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/example.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/redis_csv.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/tele.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/cli/util.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/core/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/core/clash.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/core/config.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/core/redis_client.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/crypto/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/crypto/bitget.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/crypto/gate.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/crypto/okx.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/data/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/data/dou_dict.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/data/dou_list.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/data/main.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/data/template.yaml +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/models/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/models/douzero_model.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/models/ocr_model.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/models/response.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/__init__.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/elapsed.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/etcd.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/helper.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/logger.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/mysql.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/path.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/pd.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/sleep.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/text.py +0 -0
- {pymecli-0.5.7 → pymecli-0.5.9}/utils/toml.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pymecli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
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
|
```
|
|
@@ -28,22 +28,24 @@ def sync(
|
|
|
28
28
|
):
|
|
29
29
|
"""同步mysql中grid数据到redis"""
|
|
30
30
|
engine = get_database_engine(env_path)
|
|
31
|
-
redis = get_redis_client()
|
|
31
|
+
redis = get_redis_client(env_path=env_path)
|
|
32
32
|
try:
|
|
33
33
|
|
|
34
34
|
async def _run():
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
try:
|
|
36
|
+
await grid_open(engine, redis)
|
|
37
|
+
await grid_close(engine, redis)
|
|
38
|
+
await bitget_sf_open(engine, redis)
|
|
39
|
+
await bitget_sf_close(engine, redis)
|
|
40
|
+
await bitget_ff_open(engine, redis)
|
|
41
|
+
await bitget_ff_pending(engine, redis)
|
|
42
|
+
await bitget_ff_close(engine, redis)
|
|
43
|
+
finally:
|
|
44
|
+
await redis.close()
|
|
42
45
|
|
|
43
46
|
asyncio.run(_run())
|
|
44
47
|
finally:
|
|
45
48
|
engine.dispose()
|
|
46
|
-
asyncio.run(redis.close())
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
@app.command()
|
|
@@ -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
|
)
|
|
@@ -17,14 +17,16 @@ def rsync(
|
|
|
17
17
|
):
|
|
18
18
|
"""同步mysql中grid数据到redis"""
|
|
19
19
|
engine = get_database_engine(env_path)
|
|
20
|
-
redis = get_redis_client()
|
|
20
|
+
redis = get_redis_client(env_path=env_path)
|
|
21
21
|
try:
|
|
22
22
|
|
|
23
23
|
async def _run():
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
try:
|
|
25
|
+
await grid_open(engine, redis)
|
|
26
|
+
await grid_close(engine, redis)
|
|
27
|
+
finally:
|
|
28
|
+
await redis.close()
|
|
26
29
|
|
|
27
30
|
asyncio.run(_run())
|
|
28
31
|
finally:
|
|
29
32
|
engine.dispose()
|
|
30
|
-
asyncio.run(redis.close())
|
|
@@ -18,14 +18,16 @@ def sync(
|
|
|
18
18
|
):
|
|
19
19
|
"""同步mysql中grid数据到redis"""
|
|
20
20
|
engine = get_database_engine(env_path)
|
|
21
|
-
redis = get_redis_client()
|
|
21
|
+
redis = get_redis_client(env_path=env_path)
|
|
22
22
|
try:
|
|
23
23
|
|
|
24
24
|
async def _run():
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
try:
|
|
26
|
+
await grid_open(engine, redis)
|
|
27
|
+
await grid_close(engine, redis)
|
|
28
|
+
finally:
|
|
29
|
+
await redis.close()
|
|
27
30
|
|
|
28
31
|
asyncio.run(_run())
|
|
29
32
|
finally:
|
|
30
|
-
engine.dispose()
|
|
31
|
-
asyncio.run(redis.close())
|
|
33
|
+
engine.dispose()
|
|
@@ -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.7/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
|
|
File without changes
|