1、增加了新写的8号菜单, 2、修正检查数据存在的问题,
This commit is contained in:
@@ -839,6 +839,11 @@ class ConsoleDataDownloader:
|
||||
if choice == '7':
|
||||
self.copy_data_to_target_directory()
|
||||
return
|
||||
|
||||
# 处理选项8:检查数据完整性
|
||||
if choice == '8':
|
||||
self.check_data_integrity()
|
||||
return
|
||||
|
||||
tasks = []
|
||||
if choice in ('1', '4'):
|
||||
@@ -873,6 +878,7 @@ class ConsoleDataDownloader:
|
||||
print("5. 同步数据库") # 新增选项
|
||||
print("6. 全部工作(下载+同步数据库)") # 新增选项
|
||||
print("7. 拷贝更新后的数据到目标目录") # 新增选项
|
||||
print("8. 检查数据完整性") # 新增选项
|
||||
print("0. 退出")
|
||||
|
||||
while True:
|
||||
@@ -1025,6 +1031,35 @@ class ConsoleDataDownloader:
|
||||
except Exception as e:
|
||||
print(f"\n\033[31m拷贝过程中发生异常: {str(e)}\033[0m")
|
||||
|
||||
def check_data_integrity(self):
|
||||
"""检查数据完整性,运行check_market_data.py程序"""
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
try:
|
||||
print("开始检查数据完整性...")
|
||||
|
||||
# 构建check_market_data.py的完整路径
|
||||
script_path = os.path.join(os.path.dirname(__file__), 'check_market_data.py')
|
||||
|
||||
# 运行check_market_data.py程序,直接显示输出
|
||||
result = subprocess.run(
|
||||
[sys.executable, script_path],
|
||||
stdout=None, # 不捕获标准输出,直接显示在控制台上
|
||||
stderr=None, # 不捕获错误输出,直接显示在控制台上
|
||||
encoding='utf-8'
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"\n\033[32m数据完整性检查完成!\033[0m")
|
||||
else:
|
||||
print(f"\n\033[31m数据完整性检查失败,返回码: {result.returncode}\033[0m")
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"\n\033[31m未找到check_market_data.py文件,请检查路径:\033[0m {script_path}")
|
||||
except Exception as e:
|
||||
print(f"\n\033[31m执行数据完整性检查时发生异常: {e}\033[0m")
|
||||
|
||||
def process_stock_codes(self):
|
||||
"""处理所有股票代码 - 优化版本"""
|
||||
try:
|
||||
@@ -1078,8 +1113,8 @@ def get_cached_data(code):
|
||||
def parse_args():
|
||||
"""解析命令行参数"""
|
||||
parser = argparse.ArgumentParser(description='Tushare数据更新工具')
|
||||
parser.add_argument('-c', '--choice', type=str, choices=['0', '1', '2', '3', '4', '5', '6', '7'],
|
||||
help='要执行的操作: 0=退出, 1=更新股票代码表, 2=更新指数数据, 3=更新个股数据, 4=全部更新, 5=同步数据库, 6=全部工作, 7=拷贝数据到目标目录')
|
||||
parser.add_argument('-c', '--choice', type=str, choices=['0', '1', '2', '3', '4', '5', '6', '7', '8'],
|
||||
help='要执行的操作: 0=退出, 1=更新股票代码表, 2=更新指数数据, 3=更新个股数据, 4=全部更新, 5=同步数据库, 6=全部工作, 7=拷贝数据到目标目录, 8=检查数据完整性')
|
||||
return parser.parse_args()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user