modify scripts

This commit is contained in:
oscarz
2025-06-24 10:02:28 +08:00
parent 882ee5047a
commit 12c53b043d
8 changed files with 2569 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import os
from pathlib import Path
# MySQL 配置
db_config = {
'host': 'testdb',
'user': 'root',
'password': 'mysqlpw',
'database': 'stockdb'
}
home_dir = os.path.expanduser("~")
global_host_data_dir = f'{home_dir}/hostdir/scripts_data'
global_share_data_dir = f'{home_dir}/sharedata'
# 获取当前文件所在目录
current_dir = Path(__file__).resolve().parent
# 找到项目根目录,假设项目根目录下有一个 src 文件夹
project_root = current_dir
while project_root.name != 'src' and project_root != project_root.parent:
project_root = project_root.parent
# 获取 src 目录
def get_src_directory():
return project_root
# 获取 src/config 目录
def get_src_config_directory():
return project_root / 'config'
# 获取 log 目录
def get_log_directory():
"""
获取与 src 平行的 log 目录路径。如果 log 目录不存在,则自动创建。
"""
log_dir = project_root.parent / 'log'
log_dir.mkdir(parents=True, exist_ok=True)
return log_dir